Beispiel #1
0
 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();
 }
Beispiel #2
0
 function _render()
 {
     if (!empty($this->_content)) {
         $cssClass = $this->getAttribute('cssClass');
         $wrapStart = '';
         $wrapEnd = '';
         if (!is_null($this->getAttribute('wrapTag'))) {
             if (!is_null($cssClass)) {
                 $wrapperCssClass = ' class="' . $cssClass . '"';
             }
             $wrapStart = '<' . $this->getAttribute('wrapTag') . $wrapperCssClass . '>';
             $wrapEnd = '</' . $this->getAttribute('wrapTag') . '>';
         }
         $url = $this->_content;
         $label = $url;
         if (intval($url)) {
             // link interno
             $siteMap = $this->_application->getSiteMap();
             $menu = $siteMap->getNodeById($url);
             $label = $menu->title;
             $url = org_glizy_helpers_Link::makeURL('link', array('pageId' => $url));
         }
         $output = org_glizy_helpers_Link::formatLink($url, $label, NULL, $cssClass);
         return $wrapStart . $output . $wrapEnd;
     }
     return '';
 }
Beispiel #3
0
 function recordSet2List(&$iterator, $routeUrl = '', $cssClass = array(), $maxRecord = NULL, $queryVars = array(), $getRelationValues = false)
 {
     $output = array();
     $tempCssClass = $cssClass;
     $i = 0;
     while ($iterator->hasMore()) {
         $ar =& $iterator->current();
         if ($getRelationValues) {
             $ar->setProcessRelations(true);
             $ar->buildAllRelations();
         }
         $values = $ar->getValuesAsArray($getRelationValues, true, true);
         $values = array_merge($values, $queryVars);
         if (!count($tempCssClass)) {
             $tempCssClass = $cssClass;
         }
         if (count($tempCssClass)) {
             $values['__cssClass__'] = array_shift($tempCssClass);
         }
         $values['__url__'] = org_glizy_helpers_Link::makeURL($routeUrl, $values);
         $output[] = $values;
         $iterator->next();
         $i++;
         if (!is_null($maxRecord) && $i == $maxRecord) {
             break;
         }
     }
     return $output;
 }
Beispiel #4
0
 function process()
 {
     parent::process();
     $this->_content['id'] = $this->getId();
     $this->_content['cssClass'] = $this->getAttribute('cssClass');
     $this->_content['title'] = $this->getAttributeString('title');
     $this->_content['label'] = $this->getAttributeString('label');
     $this->_content['buttonLabel'] = $this->getAttributeString('buttonLabel');
     $this->_content['value'] = __Request::get('search', '');
     if (!$this->_content['buttonLabel']) {
         $this->_content['buttonLabel'] = $this->_content['label'];
     }
     $searchPageId = $this->getAttribute('searchPageId');
     if (!is_int($searchPageId)) {
         $siteMap = $this->_application->getSiteMap();
         $menu = $siteMap->getMenuByPageType($searchPageId);
         if ($menu && $menu->isVisible) {
             $this->_content['__url__'] = org_glizy_helpers_Link::makeURL('link', array('pageId' => $menu->id));
         } else {
             $this->setAttribute('visible', false);
         }
     } else {
         $this->_content['__url__'] = org_glizy_helpers_Link::makeURL('link', array('pageId' => $searchPageId));
     }
 }
Beispiel #5
0
 function process()
 {
     // check if the user is already logged
     if ($this->_user->isLogged()) {
         $this->setAttribute('visible', false);
         $this->redirectAfterLogin();
     }
     $submitId = 'submit_' . $this->getId();
     $this->_content['id'] = $this->getId();
     $this->_content['submitName'] = $submitId;
     $this->_content['errorLabel'] = '';
     $this->_content['cssClass'] = $this->getAttribute('cssClass');
     $this->_content['userLabel'] = $this->getAttribute('userLabel');
     $this->_content['userField'] = $this->getAttribute('userField');
     $this->_content['passwordLabel'] = $this->getAttribute('passwordLabel');
     $this->_content['passwordField'] = $this->getAttribute('passwordField');
     $this->_content['registrationPage'] = $this->getAttribute('registrationPage');
     $this->_content['registrationLabel'] = $this->getAttribute('registrationLabel');
     $this->_content['confirmLabel'] = $this->getAttribute('confirmLabel');
     $this->_content['rememberLabel'] = $this->getAttribute('rememberLabel');
     $this->_content['askPasswordLabel'] = $this->getAttribute('askPasswordLabel');
     $this->_content['title'] = $this->getAttributeString('title');
     $this->_content['__url__'] = org_glizy_helpers_Link::makeURL($this->getAttribute('registrationUrl'));
     $this->_content['askPasswordUrl'] = org_glizy_helpers_Link::makeURL($this->getAttribute('askPasswordUrl'));
     if (__Request::exists($this->_content['userField']) || __Request::exists($this->_content['passwordField'])) {
         $authClass = org_glizy_ObjectFactory::createObject(__Config::get('glizy.authentication'));
         if ($authClass) {
             try {
                 $allowGroups = $this->getAttribute('allowGroups') != '' ? explode(',', $this->getAttribute('allowGroups')) : array();
                 $authClass->setAllowGroups($allowGroups);
                 $authClass->setOnlyBackendUser($this->getAttribute('backend'));
                 $authClass->setUserLanguage(__Request::get($this->getAttribute('languageField')));
                 $authClass->loginFromRequest($this->getAttribute('userField'), $this->getAttribute('passwordField'), $this->getAttribute('rememberField'), true);
                 $this->redirectAfterLogin();
             } catch (org_glizy_authentication_AuthenticationException $e) {
                 switch ($e->getCode()) {
                     case org_glizy_authentication_AuthenticationException::EMPTY_LOGINID_OR_PASSWORD:
                     case org_glizy_authentication_AuthenticationException::WRONG_LOGINID_OR_PASSWORD:
                         $this->_content['errorLabel'] = $this->getAttribute('errorLabel');
                         break;
                     case org_glizy_authentication_AuthenticationException::USER_NOT_ACTIVE:
                     case org_glizy_authentication_AuthenticationException::ACCESS_NOT_ALLOWED:
                         $this->_content['errorLabel'] = org_glizy_locale_Locale::get('GLZ_LOGIN_DISABLED');
                         break;
                 }
             }
         } else {
             // TODO mostrare errore
             $this->_content['errorLabel'] = __Config::get('glizy.authentication');
         }
     } else {
         $this->_content['errorLabel'] = org_glizy_Session::get('glizy.loginError', '');
         org_glizy_Session::remove('glizy.loginError');
     }
 }
Beispiel #6
0
 function getContent()
 {
     if (!$this->getAttribute('generateLink')) {
         return !is_null($this->_content) && $this->_content > 0 ? org_glizy_helpers_Link::makeURL('link', array('pageId' => $this->_content)) : '';
     }
     $title = $this->getAttribute('title');
     if (empty($title) && !empty($this->_content)) {
         $siteMap = $this->_application->getSiteMap();
         $page = $siteMap->getNodeById($this->_content);
         $title = $page->title;
     }
     return !is_null($this->_content) && $this->_content > 0 ? org_glizy_helpers_Link::makeLink('link', array('pageId' => $this->_content, 'title' => $title)) : '';
 }
Beispiel #7
0
 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;
     }
 }