public function execute() { $c = $this->view->getComponentById('dp'); if (stripos($this->application->getPageId(), 'picker') !== false) { // picker $sessionEx = org_glizy_ObjectFactory::createObject('org.glizy.SessionEx', $c->getId()); $mediaType = org_glizy_Request::get('mediaType', ''); if (empty($mediaType)) { $mediaType = $sessionEx->get('mediaType', 'ALL', false, false); } if (!empty($mediaType) && strtoupper($mediaType) != 'ALL') { $sessionEx->set('mediaType', $mediaType, GLZ_SESSION_EX_PERSISTENT); $c->setAttribute('query', 'all' . ucfirst(strtolower(str_replace(',', '_', $mediaType)))); // $this->setAttribute('filters', 'media_type IN (\''.str_replace(',', '\',\'',$mediaType).'\')'); } if (stripos($this->application->getPageId(), 'tiny') !== false) { $this->setComponentsVisibility('buttonsBar', false); } } else { $query = str_replace('all', '', __Request::get('tabs_state', 'allMedia')); // $query = str_replace('mediaarchive_all', '', strtolower($this->application->getPageId())); if (empty($query) || $query == 'mediaarchive') { $query = 'media'; } $query = 'all' . ucfirst($query); $c->setAttribute('query', $query); } // TODO disabilitare il pulsane aggiungi in base all'acl }
public function executeLater() { if ($this->user->isLogged() && $this->submit && $this->controller->validate()) { $ar = org_glizy_ObjectFactory::createModel('org.glizy.models.User'); $ar->load($this->user->id); $email = org_glizy_Request::get('user_email', ''); if ($email != $ar->user_loginId) { $ar2 = org_glizy_ObjectFactory::createModel('org.glizy.models.User'); if ($ar2->find(array('user_loginId' => $email)) && $ar2->user_id != $ar->user_id) { $this->view->validateAddError('L\'email è già presente nel database, usare un\'altra email'); return; } } // TODO migliorare così siamo esposti a problemi di sicurezza $fields = $ar->getFields(); foreach ($fields as $k => $v) { if ($k == 'user_password') { continue; } if (__Request::exists($k)) { $ar->{$k} = __Request::get($k); } } $password = __Request::get('user_password'); if ($password) { $ar->user_password = glz_password($password); } $ar->user_loginId = $email; $ar->user_email = $email; $ar->save(); $this->changeAction('modifyConfirm'); } }
public function executeLater() { if ($this->submit && $this->controller->validate()) { $email = org_glizy_Request::get('user_email', ''); $ar = org_glizy_ObjectFactory::createModel('org.glizy.models.User'); if ($ar->find(array('user_loginId' => $email))) { // TODO tradurre $this->view->validateAddError('L\'email è già presente nel database, usare un\'altra email o richiedere la password'); return; } $fields = $ar->getFields(); foreach ($fields as $k => $v) { if (__Request::exists($k)) { $ar->{$k} = __Request::get($k); } } $ar->user_FK_usergroup_id = __Config::get('USER_DEFAULT_USERGROUP'); $ar->user_isActive = __Config::get('USER_DEFAULT_ACTIVE_STATE'); $ar->user_password = glz_password(__Request::get('user_password')); $ar->user_loginId = $email; $ar->user_email = $email; $ar->user_dateCreation = new org_glizy_types_DateTime(); $ar->save(); $this->changeAction('registrationConfirm'); } }
function checkSwicth() { if (!is_null(org_glizy_Request::get('switchLanguage'))) { $language = org_glizy_Request::get('switchLanguage'); $this->_application->switchEditingLanguage($language); } }
function process() { if (!$this->_application->isAdmin()) { $this->_content = array(); $this->_content['label'] = $this->getAttribute('label'); $this->_content['buttonLabel'] = $this->getAttribute('buttonLabel'); $this->_content['comment'] = $this->getAttribute('comment'); $this->_content['comment1'] = org_glizy_locale_Locale::get('GLZ_SEARCH_RESULT'); $this->_content['value'] = org_glizy_Request::get('search', ''); $this->_content['result'] = null; // preg_match( '/"([^"]*)"/i', $this->_content['value'], $match ); // if ( count( $match ) ) // { // $searchArray2 = array( $match[ 1 ] ); // } // else // { // if ($this->getAttribute('explodeWords')) { // $searchArray = explode(' ', $this->_content['value']); // $searchArray2 = array(); // foreach ($searchArray as $word) // { // if (strlen($word)>=3) $searchArray2[] = $word; // } // } else { // $searchArray2 = $this->_content['value']; // } // } if (strlen($this->_content['value']) >= 3) { $pluginObj =& org_glizy_ObjectFactory::createObject('org.glizy.plugins.Search'); $this->_content['result'] = $pluginObj->run(array('search' => $this->_content['value'], 'languageId' => $this->_application->getLanguageId())); } $this->_content['total'] = org_glizy_locale_Locale::get('GLZ_SEARCH_RESULT_TOTAL') . ' ' . count($this->_content['result']); } }
function process() { $this->recordId = org_glizy_Request::get($this->getAttribute('idName'), NULL); if (is_null($this->recordId)) { return; } $dataProvider =& $this->getAttribute('dataProvider'); if ($dataProvider) { $this->ar = $dataProvider->load($this->recordId); $processCell = org_glizy_ObjectFactory::createObject($this->getAttribute('processCell'), $this->_application); if ($processCell) { $ar =& $this->ar; call_user_func_array(array($processCell, 'renderCell'), array($ar, $this->getAttribute('processCellParams'))); } $this->_content = org_glizy_ObjectFactory::createObject('org.glizy.components.RecordDetailVO', $this->ar); $ogTitle = $this->getAttribute('ogTitle'); if ($ogTitle) { org_glizy_ObjectValues::set('org.glizy.og', 'title', $this->ar->{$ogTitle}); if ($this->getAttribute('modifyBreadcrumbs')) { $evt = array('type' => GLZ_EVT_BREADCRUMBS_UPDATE, 'data' => $this->ar->{$ogTitle}); $this->dispatchEvent($evt); $evt = array('type' => GLZ_EVT_PAGETITLE_UPDATE, 'data' => $this->ar->{$ogTitle}); $this->dispatchEvent($evt); } } // TODO controllare che i dati siano stati caricati correttamento } else { // TODO generare errore, dataprovider non valid } $this->_content->__url__ = !is_null($this->getAttribute('routeUrl')) ? org_glizy_helpers_Link::makeURL($this->getAttribute('routeUrl'), $this->_content) : ''; parent::process(); }
/** * Process * * @return boolean false if the process is aborted * @access public */ function process() { $this->overrideEditableRegion = $this->getAttribute('overrideEditableRegion'); $this->_stateName = $this->getAttribute('useIdPrefix') ? $this->getId() . '_' . GLZ_STATE_SWITCH_SUFFIX : GLZ_STATE_SWITCH_SUFFIX; $this->_sessionEx = org_glizy_ObjectFactory::createObject('org.glizy.SessionEx', $this->getId()); $this->_oldState = $this->_sessionEx->get($this->_stateName); // se lo stato non è setttato lo cerca nella sessione if ($this->getAttribute('rememberState')) { $this->_currentState = $this->_sessionEx->get($this->_stateName); } if (is_null($this->_currentState)) { $this->resetState(); } $newState = org_glizy_Request::get($this->_stateName, NULL); if (!empty($newState)) { // cambio di stato // TODO // verificare che lo stato impostato sia definito $this->_currentState = org_glizy_Request::get($this->_stateName, NULL); } if ($this->_currentState == 'reset') { $this->_currentState = NULL; $this->resetState(); } $this->_currentState = strtolower($this->_currentState); $this->_sessionEx->set($this->_stateName, $this->_currentState); $customClassName = $this->getAttribute('customClass'); if (!empty($customClassName)) { $customClass =& org_glizy_ObjectFactory::createObject($customClassName, $this); // TODO // createObject purtroppo non passa i parametri in riferimento e questa è una grande limitazione $customClass->_parent =& $this; if (method_exists($customClass, $this->_currentState)) { call_user_func(array($customClass, $this->_currentState), $this->_oldState); } else { if (method_exists($customClass, 'execute_' . $this->_currentState)) { call_user_func(array($customClass, 'execute_' . $this->_currentState), $this->_oldState); } } } else { if (method_exists($this, $this->_currentState)) { call_user_func(array($this, $this->_currentState), $this->_oldState); } } $this->processChilds(); if (!empty($customClassName)) { $customClass =& org_glizy_ObjectFactory::createObject($customClassName, $this); $customClass->_parent =& $this; if (method_exists($customClass, 'executeLater_' . $this->_currentState)) { call_user_func(array($customClass, 'executeLater_' . $this->_currentState), $this->_oldState); } } }
/** * @param string $key * @param mixed $defaultValue * @param bool $readFromParams * @param bool $writeDefaultValue * @return mixed */ static function get($key, $defaultValue = NULL, $readFromParams = false, $writeDefaultValue = false) { org_glizy_Session::start(); if (!array_key_exists(org_glizy_Config::get('SESSION_PREFIX') . $key, $_SESSION)) { $value = $readFromParams ? org_glizy_Request::get($key, $defaultValue) : $defaultValue; if ($writeDefaultValue) { org_glizy_Session::set($key, $value); } } else { $value = $_SESSION[org_glizy_Config::get('SESSION_PREFIX') . $key]; } return $value; }
function get($name, $defaultValue = NULL, $readFromParams = false, $writeDefaultValue = false) { $origName = $name; $name = $this->_componentId . '_' . $name; if (!array_key_exists($name, $this->_values)) { // TODO // verificare se � meglio aggiungere $this->_pageId quando si legge dai parametri della pagian $value = $readFromParams ? org_glizy_Request::get($name, $defaultValue) : $defaultValue; if ($writeDefaultValue !== false) { $this->set($origName, $value, GLZ_SESSION_EX_VOLATILE); } } else { $value = $readFromParams ? org_glizy_Request::get($name, $this->_values[$name]['value']) : $this->_values[$name]['value']; } return $value; }
function process() { $this->recordId = org_glizy_Request::get('id', null); if (!is_null($this->recordId)) { $target =& $this->getAttribute('target'); if (is_object($target)) { $targetId = $target->getId(); $prefix = $targetId . ($this->recordId > 1 ? '@' . ($this->recordId - 1) : ''); for ($i = 0; $i < count($target->childComponents); $i++) { $target->childComponents[$i]->setAttribute('id', str_replace($targetId, $prefix, $target->childComponents[$i]->getId())); $this->addChild($target->childComponents[$i]); $target->childComponents[$i]->_parent =& $this; } $target->childComponents = array(); $this->processChilds(); } else { // TODO // visualizzare errore } } }
/** * Render * * @return string * @access public */ function render() { $this->renderChilds(); $responseDate = gmstrftime('%Y-%m-%dT%T') . 'Z'; $error = $this->_application->getError(); $requestAttribs = ''; $content = ''; if (empty($error)) { for ($i = 0; $i < count($this->_output); $i++) { if ($this->_output[$i]['editableRegion'] != 'content') { continue; } $content .= $this->_output[$i]['code']; } $params =& org_glizy_Request::_getValuesArray(); unset($params['__url__']); unset($params['__back__url__']); foreach ($params as $k => $v) { if ($v[GLZ_REQUEST_TYPE] == GLZ_REQUEST_GET) { $requestAttribs .= ' ' . $k . '="' . htmlentities($v[GLZ_REQUEST_VALUE]) . '"'; } } } else { $content = $error; } $requestUrl = org_glizy_Routing::$baseUrl; $charset = GLZ_CHARSET; $output = <<<EOD <?xml version="1.0" encoding="{$charset}"?> <OAI-PMH xmlns="http://www.openarchives.org/OAI/2.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/ http://www.openarchives.org/OAI/2.0/OAI-PMH.xsd"> \t\t<responseDate>{$responseDate}</responseDate> \t\t<request {$requestAttribs}>{$requestUrl}</request> \t\t{$content} </OAI-PMH> EOD; return $output; }
public function executeLater($email) { if ($this->submit && $this->controller->validate()) { $ar = org_glizy_ObjectFactory::createModel('org.glizy.models.User'); if (!$ar->find(array('user_email' => $email))) { // utente non trovato $this->view->validateAddError(__T('MW_LOSTPASSWORD_ERROR')); return false; } // utente trovato // genera una nuova password e la invia per email glz_import('org.glizy.helpers.Mail'); // invia la notifica all'utente $subject = org_glizy_locale_Locale::get('MW_LOSTPASSWORD_EMAIL_SUBJECT'); $body = org_glizy_locale_Locale::get('MW_LOSTPASSWORD_EMAIL_BODY'); $body = str_replace('##USER##', $email, $body); $body = str_replace('##HOST##', org_glizy_helpers_Link::makeSimpleLink(GLZ_HOST, GLZ_HOST), $body); $body = str_replace('##PASSWORD##', $ar->user_password, $body); org_glizy_helpers_Mail::sendEmail(array('email' => org_glizy_Request::get('email', ''), 'name' => $ar->user_firstName . ' ' . $ar->user_lastName), array('email' => org_glizy_Config::get('SMTP_EMAIL'), 'name' => org_glizy_Config::get('SMTP_SENDER')), $subject, $body); $this->changeAction('lostPasswordConfirm'); } }
function process() { $this->sessionEx = new org_glizy_SessionEx($this->getId()); $this->_command = org_glizy_Request::get($this->getId() . '_command'); $this->rememberMode = $this->getAttribute('rememberMode') == 'persistent' ? GLZ_SESSION_EX_PERSISTENT : GLZ_SESSION_EX_VOLATILE; if ($this->_command == 'RESET') { $this->sessionEx->remove('filters_filters'); } else { $name = $this->getId() . '_filters'; $defValue = ''; if ($this->getAttribute('rememberValues')) { $defValue = $this->sessionEx->get($name); } $this->filters = __Request::get($name, $defValue); $this->sessionEx->set($name, $this->filters, $this->rememberMode); $this->filters = json_decode($this->filters); } if (!$this->filters) { $this->filters = array(); } parent::process(); }
function loadContent($name, $bindToField = NULL, $value = NULL) { if (empty($bindToField)) { $bindToField = $name; } if ($this->_command == 'RESET') { $this->_filters[$bindToField] = ''; } else { if ($this->getAttribute('rememberValues')) { $defValue = !is_null($this->sessionEx) ? $this->sessionEx->get($name, '') : ''; $this->_filters[$bindToField] = org_glizy_Request::get($name, $defValue); } else { $this->_filters[$bindToField] = org_glizy_Request::get($name, ''); } } if (!is_null($this->sessionEx)) { $this->sessionEx->set($name, $this->_filters[$bindToField], $this->rememberMode); } if ($this->getAttribute('setRequest')) { __Request::set($name, $this->_filters[$bindToField]); } return $this->_filters[$bindToField]; }
function process() { $this->recordId = org_glizy_Request::get($this->getAttribute('idName'), NULL); if (is_null($this->recordId)) { return; } $dataProvider =& $this->getAttribute('dataProvider'); $ar =& $dataProvider->getNewObject(); $versionFieldName = $ar->getVersionFieldName(); $languageFieldName = $ar->getLanguageFieldName(); if (is_null($versionFieldName)) { $ar->load($this->recordId, $this->getAttribute('query')); $this->_content = $ar->getValuesAsArray($this->getAttribute('getRelations'), true); } else { $query = $this->getAttribute('query'); if (is_null($query)) { $result = $ar->find(array($ar->getPrimaryKey() => $this->recordId, $versionFieldName => 'PUBLISHED', $languageFieldName => $this->_application->getLanguageId())); } else { $result = $ar->load($this->recordId, null, $query); } if (!$result) { // TODO // record non trovato } else { $this->_content = $ar->getValuesAsArray($this->getAttribute('getRelations')); } } $this->_content['__url__'] = !is_null($this->getAttribute('routeUrl')) ? org_glizy_helpers_Link::makeURL($this->getAttribute('routeUrl'), $this->_content) : ''; // crea i figli if ($this->getAttribute('createModelComponents')) { $this->canHaveChilds = true; $className = $dataProvider->getRecordClassName(); $this->createChildsFromModel($className); $this->processChilds(); $this->canHaveChilds = false; } }
function loadContent($name, $bindToField = NULL) { if (empty($bindToField)) { $bindToField = $name; } return org_glizy_Request::get($bindToField, $this->_content[$bindToField]); }
private function checkSwitchLanguage() { $language = org_glizy_Request::get('language', NULL); if (!is_null($language) && $language != $this->_language) { // cambio lingua $this->log("change language", GLZ_LOG_SYSTEM); $ar = org_glizy_ObjectFactory::createModel('org.glizycms.core.models.Language'); $ar->language_code = $language; $ar->find(); org_glizy_Session::set('glizy.language', $ar->language_code); org_glizy_Session::set('glizy.languageId', $ar->language_id); org_glizy_ObjectValues::set('org.glizy', 'languageId', $ar->language_id); $this->_languageId = $ar->language_id; $this->_language = $ar->language_code; // ricarica la struttura del sito per avere i titoli aggiornati $this->_initSiteMap(true); // controlla se il routing ha definito un urlResolver $speakingUrlManager = $this->retrieveProxy('org.glizycms.speakingUrl.Manager'); $urlResolver = $speakingUrlManager->getResolver(__Request::get('cms:urlResolver', 'org.glizycms.core.models.Content')); $url = $urlResolver->makeUrlFromRequest(); org_glizy_helpers_Navigation::gotoUrl($url); } }
function utf8_decode($values) { if (is_array($values)) { $keys = array_keys($values); $count = count($values); for ($i = 0; $i < $count; $i++) { if (is_array($values[$keys[$i]])) { $values[$keys[$i]] = org_glizy_Request::utf8_decode($values[$keys[$i]]); } else { if (function_exists('iconv')) { $output[$keys[$i]] = iconv("UTF-8", "CP1252", $values[$keys[$i]]); } else { $output[$keys[$i]] = utf8_decode($values[$keys[$i]]); } } } return $values; } else { if (function_exists('iconv')) { return iconv("UTF-8", "CP1252", $values); } else { return utf8_decode($values); } } }
private function startProcessAjax() { header('Cache-Control: no-cache'); header('Pragma: no-cache'); header('Expires: -1'); $this->_rootComponent->resetDoLater(); $this->_rootComponent->init(); $this->_rootComponent->execDoLater(); $evt = array('type' => GLZ_EVT_START_PROCESS); $this->dispatchEvent($evt); $ajaxTarget = org_glizy_Request::get('ajaxTarget'); $targetComponent =& $this->_rootComponent->getComponentById($ajaxTarget); if (is_null($targetComponent)) { // prima prova a creare i figli in modo ritardato // questo è usato nella gestione degli stati $this->_rootComponent->deferredChildCreation(true); $targetComponent =& $this->_rootComponent->getComponentById($ajaxTarget); // se il targetComponent è ancora nullo // prova a lanciare il process di tutti i figli if (is_null($targetComponent)) { $this->_rootComponent->process(); $targetComponent =& $this->_rootComponent->getComponentById($ajaxTarget); if (is_null($targetComponent)) { return false; } } } $ajaxMethod = __Request::get('ajaxMethod', 'process_ajax'); if (method_exists($targetComponent, $ajaxMethod)) { org_glizy_Request::remove('pageId'); org_glizy_Request::remove('ajaxTarget'); $result = $targetComponent->{$ajaxMethod}(); } else { $result = $this->processAjaxCallController($targetComponent); } if (!$targetComponent->controllerDirectOutput() && !is_array($result) && !is_object($result)) { $result = array('status' => $result === true ? 'success' : 'error'); } if (is_array($result) && isset($result['html'])) { header("Content-Type: " . $this->contentType . "; charset=" . __Config::get('CHARSET')); echo $result['html']; } else { header("Content-Type: application/json; charset=utf-8"); echo json_encode($result); } return true; }