protected function _getMainSection() { try { $elements = array(); $input = $this->_controller->getRequest()->getPost(null); #$valueSort = $this->_controller->getRequest()->get(Sitengine_Env::PARAM_SORT); #$valueOrder = $this->_controller->getRequest()->get(Sitengine_Env::PARAM_ORDER); #$valuePage = $this->_controller->getRequest()->get(Sitengine_Env::PARAM_PAGE); $table = $this->_controller->getFrontController()->getBlogPackage()->getBlogsTable(); $table->setTranscript($this->_controller->getPreferences()->getTranscript()); $transcripts = $table->getTranscripts(); ######################################################################## #### FILTER INPUT ######################################################################## $fieldsNormal = array('id' => '', 'mdate' => '', 'slug' => ''); foreach ($transcripts->get() as $index => $symbol) { $fieldsNormal['titleLang' . $index] = ''; $fieldsNormal['markupLang' . $index] = ''; } $fieldsOnOff = array('publish' => 1); if ($this->_inputMode == Sitengine_Env::INPUTMODE_UPDATE) { require_once 'Sitengine/Form/TranscriptsPayloads.php'; $payloads = new Sitengine_Form_TranscriptsPayloads($transcripts); $payloads->start($this->_controller->getRequest()->get(Sitengine_Env::PARAM_PAYLOAD_NAME)); $stored = $this->_controller->getFrontController()->getBlogPackage()->getBlogsTable()->complementRow($this->_controller->getEntity()->getRow()); $data = Sitengine_Controller_Request_Http::filterUpdateDeprecated(sizeof($input), $input, $fieldsNormal, $fieldsOnOff, $stored); $data = array_merge($stored, $data); # set dates to timezone /* $name = 'cdate'; $date = new Zend_Date($stored[$name], Zend_Date::ISO_8601, $this->_controller->getLocale()); $date->setTimezone($this->_controller->getPreferences()->getTimezone()); $data[$name] = $date->get(Zend_Date::DATE_FULL).' '; $data[$name] .= $date->get(Zend_Date::TIME_FULL); */ /* $name = 'mdate'; $date = new Zend_Date($stored[$name], Zend_Date::ISO_8601, $this->_controller->getLocale()); $date->setTimezone($this->_controller->getPreferences()->getTimezone()); $data[$name] = $date->get(Zend_Date::DATE_LONG).' '; $data[$name] .= $date->get(Zend_Date::TIME_LONG); */ $args = array(Sitengine_Env::PARAM_ID => $stored['slug']); $route = $this->_controller->getFrontController()->getRouter()->getRoute(Sitengine_Blog_Backend_Front::ROUTE_BLOGS_SHARP); $queryUpdate = $this->_controller->getRequest()->getBasePath() . '/' . $route->assemble($args, true); $childActions = array(); $args = array(Sitengine_Env::PARAM_ANCESTORID => $stored['slug']); $route = $this->_controller->getFrontController()->getRouter()->getRoute(Sitengine_Blog_Backend_Front::ROUTE_BLOGS_POSTS); $uri = $this->_controller->getRequest()->getBasePath() . '/' . $route->assemble($args, true); $childActions['postList'] = array('uri' => $uri, 'label' => $this->_controller->getTranslate()->translate('labelsChildActionsSectionPostsIndex'), 'postfix' => ' (' . $this->_controller->getViewHelper()->countPosts($stored['id']) . ')'); $hiddens = array(Sitengine_Env::PARAM_METHOD => Sitengine_Env::METHOD_PUT, Sitengine_Env::PARAM_PAYLOAD_NAME => $payloads->getName(), Sitengine_Env::PARAM_MDATE => $stored['mdate']); $args = array(Sitengine_Env::PARAM_ID => $stored['slug']); $route = $this->_controller->getFrontController()->getRouter()->getRoute(Sitengine_Blog_Backend_Front::ROUTE_BLOGS_SHARP); $submitUri = $this->_controller->getRequest()->getBasePath() . '/' . $route->assemble($args, true); $title = $stored['titleLang' . $transcripts->getIndex()]; $title = $title != '' ? $title : $stored['titleLang' . $transcripts->getDefaultIndex()]; } else { require_once 'Sitengine/Form/TranscriptsPayloads.php'; $payloads = new Sitengine_Form_TranscriptsPayloads($transcripts); $payloads->start(); $data = Sitengine_Controller_Request_Http::filterInsertDeprecated(sizeof($input), $input, $fieldsNormal, $fieldsOnOff); $gid = $this->_controller->getPermiso()->getDirectory()->getGroupId($this->_controller->getFrontController()->getBlogPackage()->getOwnerGroup()); $data[Sitengine_Permiso::FIELD_GID] = !is_null($gid) ? $gid : Sitengine_Permiso::GID_ADMINISTRATORS; $data[Sitengine_Permiso::FIELD_UID] = $this->_controller->getPermiso()->getAuth()->getId(); $hiddens = array(Sitengine_Env::PARAM_PAYLOAD_NAME => $payloads->getName()); $args = array(); $route = $this->_controller->getFrontController()->getRouter()->getRoute(Sitengine_Blog_Backend_Front::ROUTE_BLOGS_NEW); $submitUri = $this->_controller->getRequest()->getBasePath() . '/' . $route->assemble($args, true); $title = $this->_controller->getTranslate()->translate('labelsViewformInsertTitle'); } #Sitengine_Debug::print_r($data); ######################################################################## #### ELEMENTS ######################################################################## if ($payloads->isMain()) { /* if( (!$data['id']) || # on insert (isset($data[Sitengine_Permiso::FIELD_UID]) && $data[Sitengine_Permiso::FIELD_UID]==$this->_controller->getPermiso()->getAuth()->getId()) || # owners ok #$this->_controller->getPermiso()->getUser()->hasSupervisorRights() || # supervisors ok #$this->_controller->getPermiso()->getUser()->hasModeratorRights() # moderators ok $this->_controller->getPermiso()->getDirectory()->userIsMember($this->_controller->getPermiso()->getAuth()->getId(), Sitengine_Permiso::GID_ADMINISTRATORS) ) { $n = Sitengine_Permiso::FIELD_UID; $e = new Sitengine_Form_Element($n, $data[$n]); $e->setClass('viewFormSelect'); $e->setId('viewForm'.$n); $users = $this->_controller->getPermiso()->getDirectory()->getAllUsers(); $elements[$n] = $e->getSelect($users); $n = Sitengine_Permiso::FIELD_GID; $e = new Sitengine_Form_Element($n, $data[$n]); $e->setClass('viewFormSelect'); $e->setId('viewForm'.$n); $groups = $this->_controller->getPermiso()->getDirectory()->getAllGroups(); $groups = array_merge($this->_controller->getTranslate()->translateGroup('fieldValsGid')->toArray(), $groups); $elements[$n] = $e->getSelect($groups); $n = Sitengine_Permiso::FIELD_RAG; $e = new Sitengine_Form_Element($n, '1'); $e->setClass('viewFormCheckbox'); $e->setId('viewForm'.$n); $elements[$n] = $e->getCheckbox($data[$n]); $n = Sitengine_Permiso::FIELD_RAW; $e = new Sitengine_Form_Element($n, '1'); $e->setClass('viewFormCheckbox'); $e->setId('viewForm'.$n); $elements[$n] = $e->getCheckbox($data[$n]); $n = Sitengine_Permiso::FIELD_UAG; $e = new Sitengine_Form_Element($n, '1'); $e->setClass('viewFormCheckbox'); $e->setId('viewForm'.$n); $elements[$n] = $e->getCheckbox($data[$n]); $n = Sitengine_Permiso::FIELD_UAW; $e = new Sitengine_Form_Element($n, '1'); $e->setClass('viewFormCheckbox'); $e->setId('viewForm'.$n); $elements[$n] = $e->getCheckbox($data[$n]); $n = Sitengine_Permiso::FIELD_DAG; $e = new Sitengine_Form_Element($n, '1'); $e->setClass('viewFormCheckbox'); $e->setId('viewForm'.$n); $elements[$n] = $e->getCheckbox($data[$n]); $n = Sitengine_Permiso::FIELD_DAW; $e = new Sitengine_Form_Element($n, '1'); $e->setClass('viewFormCheckbox'); $e->setId('viewForm'.$n); $elements[$n] = $e->getCheckbox($data[$n]); } */ $n = 'titleLang' . $transcripts->getDefaultIndex(); $e = new Sitengine_Form_Element($n, $data[$n]); $e->setClass('viewFormInput'); $e->setId('viewForm' . $n); $elements['title'] = $e->getText(40); $n = 'markupLang' . $payloads->getTranscriptIndex(); $e = new Sitengine_Form_Element($n, $data[$n]); $e->setClass('viewFormTextarea'); $e->setId('viewForm' . $n); $elements[$n] = $e->getTextarea(40, 10); $n = 'publish'; $e = new Sitengine_Form_Element($n, '1'); $e->setClass('viewFormCheckbox'); $e->setId('viewForm' . $n); $elements[$n] = $e->getCheckbox($data[$n]); $n = 'slug'; $e = new Sitengine_Form_Element($n, $data[$n]); $e->setClass('viewFormInput'); $e->setId('viewForm' . $n); $elements[$n] = $e->getText(40); } ######################################################################## #### CONTENT PAYLOAD SECTION TITLE ######################################################################## $contentSectionTitle = $this->_controller->getTranslate()->translate('labelsViewformContentSectionTitleDefault'); if (sizeof($transcripts->get()) > 1) { if (!$payloads->isMain()) { $symbol = $payloads->getTranscriptSymbol(); } else { $symbol = $transcripts->getDefaultSymbol(); } $contentSectionTitle .= ' (' . $this->_controller->getTranslate()->translate('languages' . ucfirst($symbol)) . ')'; } ######################################################################## #### PAYLOAD NAV DATA ######################################################################## $payloadNav = array(); ######################################################################## #### COLLECT ALL DATA ######################################################################## foreach ($hiddens as $k => $v) { $hiddens[$k] = Sitengine_Form_Element::getHidden($k, $v); } return array('payloadName' => $payloads->getName(), 'payloadIsMain' => $payloads->isMain(), 'payloadIsDefaultTranscript' => $payloads->isDefaultTranscript(), 'queryUpdate' => isset($queryUpdate) ? $queryUpdate : '', 'title' => $title, 'contentSectionTitle' => $contentSectionTitle, 'inputMode' => $this->_inputMode, 'hiddens' => implode('', $hiddens), 'submitUri' => $submitUri, 'ELEMENTS' => $elements, 'CHILDACTIONS' => isset($childActions) ? $childActions : array(), 'PAYLOADNAV' => $payloadNav, 'DATA' => $data); } catch (Exception $exception) { require_once 'Sitengine/Blog/Backend/Blogs/Exception.php'; throw new Sitengine_Blog_Backend_Blogs_Exception('form page error', $exception); } }
protected function _getMainSection() { try { $elements = array(); $input = $this->_controller->getRequest()->getPost(null); #$valueSort = $this->_controller->getRequest()->get(Sitengine_Env::PARAM_SORT); #$valueOrder = $this->_controller->getRequest()->get(Sitengine_Env::PARAM_ORDER); #$valuePage = $this->_controller->getRequest()->get(Sitengine_Env::PARAM_PAGE); $table = $this->_controller->getFrontController()->getProtoPackage()->getCouldiesTable(); $table->setTranscript($this->_controller->getPreferences()->getTranscript()); $transcripts = $table->getTranscripts(); $displayPermissionSettings = false; ######################################################################## #### FILTER INPUT ######################################################################## $fields = array('id' => '', Sitengine_Permiso::FIELD_UID => '', Sitengine_Permiso::FIELD_GID => '', Sitengine_Permiso::FIELD_RAG => 1, Sitengine_Permiso::FIELD_RAW => 1, Sitengine_Permiso::FIELD_UAG => 1, Sitengine_Permiso::FIELD_UAW => 0, Sitengine_Permiso::FIELD_DAG => 1, Sitengine_Permiso::FIELD_DAW => 0, 'mdate' => '', 'type' => 'fan', 'sorting' => '', 'displayThis' => 1, 'publish' => 1, 'locked' => 0); foreach ($transcripts->get() as $index => $symbol) { $fields['titleLang' . $index] = ''; $fields['textLang' . $index] = ''; } if ($this->_inputMode == Sitengine_Env::INPUTMODE_UPDATE) { require_once 'Sitengine/Form/TranscriptsPayloads.php'; $payloads = new Sitengine_Form_TranscriptsPayloads($transcripts); $payloads->start($this->_controller->getRequest()->get(Sitengine_Env::PARAM_PAYLOAD_NAME)); $stored = $this->_controller->getFrontController()->getProtoPackage()->getCouldiesTable()->complementRow($this->_controller->getEntity()->getRow()); $data = Sitengine_Controller_Request_Http::filterUpdate(sizeof($input), $input, $fields, $stored); $data = array_merge($stored, $data); $args = array(Sitengine_Env::PARAM_GREATANCESTORID => $this->_controller->getEntity()->getGreatAncestorId(), Sitengine_Env::PARAM_ANCESTORID => $this->_controller->getEntity()->getAncestorId(), Sitengine_Env::PARAM_ID => $stored['id']); $route = $this->_controller->getFrontController()->getRouter()->getRoute(Sitengine_Proto_Backend_Front::ROUTE_GOODIES_SHOULDIES_COULDIES_SHARP); $uri = $this->_controller->getRequest()->getBasePath() . '/' . $route->assemble($args, true); $queryUpdate = $uri; $hiddens = array(Sitengine_Env::PARAM_METHOD => Sitengine_Env::METHOD_PUT, Sitengine_Env::PARAM_PAYLOAD_NAME => $payloads->getName(), Sitengine_Env::PARAM_MDATE => $stored['mdate']); $args = array(Sitengine_Env::PARAM_GREATANCESTORID => $this->_controller->getEntity()->getGreatAncestorId(), Sitengine_Env::PARAM_ANCESTORID => $this->_controller->getEntity()->getAncestorId(), Sitengine_Env::PARAM_ID => $stored['id']); $route = $this->_controller->getFrontController()->getRouter()->getRoute(Sitengine_Proto_Backend_Front::ROUTE_GOODIES_SHOULDIES_COULDIES_SHARP); $submitUri = $this->_controller->getRequest()->getBasePath() . '/' . $route->assemble($args, true); $title = $stored['titleLang' . $transcripts->getIndex()]; $title = $title != '' ? $title : $stored['titleLang0']; if ($data[Sitengine_Permiso::FIELD_UID] == $this->_controller->getPermiso()->getAuth()->getId() || $this->_controller->getPermiso()->getDirectory()->userIsMember($this->_controller->getPermiso()->getAuth()->getId(), Sitengine_Permiso::GID_ADMINISTRATORS)) { $displayPermissionSettings = true; } } else { require_once 'Sitengine/Form/TranscriptsPayloads.php'; $payloads = new Sitengine_Form_TranscriptsPayloads($transcripts); $payloads->start(); $data = Sitengine_Controller_Request_Http::filterInsert(sizeof($input), $input, $fields); $gid = $this->_controller->getPermiso()->getDirectory()->getGroupId($this->_controller->getFrontController()->getProtoPackage()->getOwnerGroup()); $data[Sitengine_Permiso::FIELD_GID] = !is_null($gid) ? $gid : Sitengine_Permiso::GID_ADMINISTRATORS; $data[Sitengine_Permiso::FIELD_UID] = $this->_controller->getPermiso()->getAuth()->getId(); # set some defaults... $n = 'sorting'; if (array_key_exists($n, $input)) { $data[$n] = $input[$n]; } else { $q = 'SELECT MAX(sorting) AS maxSorting FROM ' . $this->_controller->getFrontController()->getProtoPackage()->getCouldiesTableName(); $q .= ' WHERE '; #.Sitengine_Permiso::FIELD_OID.' = "'.$this->_controller->getPermiso()->getOrganization()->getId().'"'; $q .= ' shouldyId = "' . $this->_controller->getEntity()->getAncestorId() . '"'; $statement = $this->_controller->getDatabase()->prepare($q); $statement->execute(); $result = $statement->fetchAll(); $data[$n] = $result[0]['maxSorting'] + 10; } $n = 'titleLang0'; if (array_key_exists($n, $input)) { $data[$n] = $input[$n]; } else { $data[$n] = 'Couldy Record (Language 0/Default)'; } $n = 'titleLang1'; if (array_key_exists($n, $input)) { $data[$n] = $input[$n]; } else { $data[$n] = 'Couldy Record (Language 1)'; } $hiddens = array(Sitengine_Env::PARAM_PAYLOAD_NAME => $payloads->getName()); $args = array(Sitengine_Env::PARAM_GREATANCESTORID => $this->_controller->getEntity()->getGreatAncestorId(), Sitengine_Env::PARAM_ANCESTORID => $this->_controller->getEntity()->getAncestorId()); $route = $this->_controller->getFrontController()->getRouter()->getRoute(Sitengine_Proto_Backend_Front::ROUTE_GOODIES_SHOULDIES_COULDIES_NEW); $submitUri = $this->_controller->getRequest()->getBasePath() . '/' . $route->assemble($args, true); $title = $this->_controller->getTranslate()->translate('formViewInsertTitle'); $displayPermissionSettings = true; } #Sitengine_Debug::print_r($data); $data['uidOptions'] = $this->_controller->getPermiso()->getDirectory()->getAllUsers(); $data['gidOptions'] = array_merge($this->_controller->getTranslate()->translateGroup('fieldValsGid')->toArray(), $this->_controller->getPermiso()->getDirectory()->getAllGroups()); ######################################################################## #### CONTENT PAYLOAD SECTION TITLE ######################################################################## $contentSectionTitle = $this->_controller->getTranslate()->translate('formViewContentSectionTitleDefault'); if (sizeof($transcripts->get()) > 1) { if (!$payloads->isMain()) { $symbol = $payloads->getTranscriptSymbol(); } else { $symbol = $transcripts->getDefaultSymbol(); } $contentSectionTitle .= ' (' . $this->_controller->getTranslate()->translate('languages' . ucfirst($symbol)) . ')'; } ######################################################################## #### PAYLOAD NAV DATA ######################################################################## $payloadNav = array(); if ($this->_inputMode == Sitengine_Env::INPUTMODE_UPDATE) { $args = array(Sitengine_Env::PARAM_GREATANCESTORID => $this->_controller->getEntity()->getGreatAncestorId(), Sitengine_Env::PARAM_ANCESTORID => $this->_controller->getEntity()->getAncestorId(), Sitengine_Env::PARAM_ID => $stored['id']); $query = array(Sitengine_Env::PARAM_PAYLOAD_NAME => $payloads->getMainName()); $route = $this->_controller->getFrontController()->getRouter()->getRoute(Sitengine_Proto_Backend_Front::ROUTE_GOODIES_SHOULDIES_COULDIES_SHARP); $uri = $this->_controller->getRequest()->getBasePath() . '/' . $route->assemble($args, true); $uri .= Sitengine_Controller_Request_Http::makeNameValueQuery($query); $payloadNav[$payloads->getMainName()] = array('uri' => $uri, 'label' => $this->_controller->getTranslate()->translate('formViewPayloadNavTitleMain')); foreach ($transcripts->get() as $index => $symbol) { $currentPayload = $payloads->getTranscriptNamePrefix() . '_' . $symbol; $args = array(Sitengine_Env::PARAM_GREATANCESTORID => $this->_controller->getEntity()->getGreatAncestorId(), Sitengine_Env::PARAM_ANCESTORID => $this->_controller->getEntity()->getAncestorId(), Sitengine_Env::PARAM_ID => $stored['id']); $query = array(Sitengine_Env::PARAM_PAYLOAD_NAME => $currentPayload); $route = $this->_controller->getFrontController()->getRouter()->getRoute(Sitengine_Proto_Backend_Front::ROUTE_GOODIES_SHOULDIES_COULDIES_SHARP); $uri = $this->_controller->getRequest()->getBasePath() . '/' . $route->assemble($args, true); $uri .= Sitengine_Controller_Request_Http::makeNameValueQuery($query); if (sizeof($transcripts->get()) > 1) { $label = $this->_controller->getTranslate()->translate('languages' . ucfirst($symbol)); } else { $label = $this->_controller->getTranslate()->translate('formViewContentSectionTitleDefault'); } $payloadNav[$currentPayload] = array('uri' => $uri, 'label' => $label); } } ######################################################################## #### COLLECT ALL DATA ######################################################################## foreach ($hiddens as $k => $v) { $hiddens[$k] = Sitengine_Form_Element::getHidden($k, $v); } return array('displayPermissionSettings' => $displayPermissionSettings, 'queryUpdate' => isset($queryUpdate) ? $queryUpdate : '', 'title' => $title, 'contentSectionTitle' => $contentSectionTitle, 'inputMode' => $this->_inputMode, 'hiddens' => implode('', $hiddens), 'submitUri' => $submitUri, 'ELEMENTS' => $elements, 'PAYLOADNAV' => $payloadNav, 'Payloads' => $payloads, 'DATA' => $data); } catch (Exception $exception) { require_once 'Sitengine/Proto/Backend/Goodies/Shouldies/Couldies/Exception.php'; throw new Sitengine_Proto_Backend_Goodies_Shouldies_Couldies_Exception('form page error', $exception); } }
protected function _getMainSection() { try { $elements = array(); $input = $this->_controller->getRequest()->getPost(null); #$valueSort = $this->_controller->getRequest()->get(Sitengine_Env::PARAM_SORT); #$valueOrder = $this->_controller->getRequest()->get(Sitengine_Env::PARAM_ORDER); #$valuePage = $this->_controller->getRequest()->get(Sitengine_Env::PARAM_PAGE); $table = $this->_controller->getFrontController()->getBlogPackage()->getFilesTable(); $table->setTranscript($this->_controller->getPreferences()->getTranscript()); $transcripts = $table->getTranscripts(); ######################################################################## #### FILTER INPUT ######################################################################## $fieldsNormal = array('id' => '', 'mdate' => '', 'sorting' => ''); foreach ($transcripts->get() as $index => $symbol) { $fieldsNormal['titleLang' . $index] = ''; $fieldsNormal['markupLang' . $index] = ''; } $fieldsOnOff = array('publish' => 1); if ($this->_inputMode == Sitengine_Env::INPUTMODE_UPDATE) { require_once 'Sitengine/Form/TranscriptsPayloads.php'; $payloads = new Sitengine_Form_TranscriptsPayloads($transcripts); $payloads->start($this->_controller->getRequest()->get(Sitengine_Env::PARAM_PAYLOAD_NAME)); $stored = $this->_controller->getFrontController()->getBlogPackage()->getFilesTable()->complementRow($this->_controller->getEntity()->getRow()); $data = Sitengine_Controller_Request_Http::filterUpdateDeprecated(sizeof($input), $input, $fieldsNormal, $fieldsOnOff, $stored); $data = array_merge($stored, $data); # set dates to timezone /* $name = 'cdate'; $date = new Zend_Date($stored[$name], Zend_Date::ISO_8601, $this->_controller->getLocale()); $date->setTimezone($this->_controller->getPreferences()->getTimezone()); $data[$name] = $date->get(Zend_Date::DATE_FULL).' '; $data[$name] .= $date->get(Zend_Date::TIME_FULL); */ /* $name = 'mdate'; $date = new Zend_Date($stored[$name], Zend_Date::ISO_8601, $this->_controller->getLocale()); $date->setTimezone($this->_controller->getPreferences()->getTimezone()); $data[$name] = $date->get(Zend_Date::DATE_LONG).' '; $data[$name] .= $date->get(Zend_Date::TIME_LONG); */ $args = array(Sitengine_Env::PARAM_GREATANCESTORID => $this->_controller->getEntity()->getGreatAncestorSlug(), Sitengine_Env::PARAM_ANCESTORID => $this->_controller->getEntity()->getAncestorId(), Sitengine_Env::PARAM_ID => $stored['id']); $route = $this->_controller->getFrontController()->getRouter()->getRoute(Sitengine_Blog_Backend_Front::ROUTE_BLOGS_POSTS_FILES_SHARP); $queryUpdate = $this->_controller->getRequest()->getBasePath() . '/' . $route->assemble($args, true); $hiddens = array(Sitengine_Env::PARAM_METHOD => Sitengine_Env::METHOD_PUT, Sitengine_Env::PARAM_PAYLOAD_NAME => $payloads->getName(), Sitengine_Env::PARAM_MDATE => $stored['mdate']); $args = array(Sitengine_Env::PARAM_GREATANCESTORID => $this->_controller->getEntity()->getGreatAncestorSlug(), Sitengine_Env::PARAM_ANCESTORID => $this->_controller->getEntity()->getAncestorId(), Sitengine_Env::PARAM_ID => $stored['id']); $route = $this->_controller->getFrontController()->getRouter()->getRoute(Sitengine_Blog_Backend_Front::ROUTE_BLOGS_POSTS_FILES_SHARP); $submitUri = $this->_controller->getRequest()->getBasePath() . '/' . $route->assemble($args, true); $title = $stored['titleLang' . $transcripts->getIndex()]; $title = $title != '' ? $title : $stored['titleLang0']; $n = 'uri'; $e = new Sitengine_Form_Element($n, preg_replace('/&/', '&', $stored['file1OriginalUri'])); $e->setClass('viewFormInput'); $e->setId('viewForm' . $n); $elements[$n] = $e->getText(60); } else { require_once 'Sitengine/Form/TranscriptsPayloads.php'; $payloads = new Sitengine_Form_TranscriptsPayloads($transcripts); $payloads->start(); $data = Sitengine_Controller_Request_Http::filterInsertDeprecated(sizeof($input), $input, $fieldsNormal, $fieldsOnOff); $gid = $this->_controller->getPermiso()->getDirectory()->getGroupId($this->_controller->getFrontController()->getBlogPackage()->getOwnerGroup()); $data[Sitengine_Permiso::FIELD_GID] = !is_null($gid) ? $gid : Sitengine_Permiso::GID_ADMINISTRATORS; $data[Sitengine_Permiso::FIELD_UID] = $this->_controller->getPermiso()->getAuth()->getId(); # set some defaults... $n = 'sorting'; if (array_key_exists($n, $input)) { $data[$n] = $input[$n]; } else { $q = 'SELECT MAX(sorting) AS maxSorting FROM ' . $this->_controller->getFrontController()->getBlogPackage()->getFilesTableName(); $q .= ' WHERE '; #.Sitengine_Permiso::FIELD_OID.' = "'.$this->_controller->getPermiso()->getOrganization()->getId().'"'; $q .= ' parentId = "' . $this->_controller->getEntity()->getAncestorId() . '"'; $statement = $this->_controller->getDatabase()->prepare($q); $statement->execute(); $result = $statement->fetchAll(); $data[$n] = $result[0]['maxSorting'] + 10; } $hiddens = array(Sitengine_Env::PARAM_PAYLOAD_NAME => $payloads->getName()); $args = array(Sitengine_Env::PARAM_GREATANCESTORID => $this->_controller->getEntity()->getGreatAncestorSlug(), Sitengine_Env::PARAM_ANCESTORID => $this->_controller->getEntity()->getAncestorId()); $route = $this->_controller->getFrontController()->getRouter()->getRoute(Sitengine_Blog_Backend_Front::ROUTE_BLOGS_POSTS_FILES_NEW); $submitUri = $this->_controller->getRequest()->getBasePath() . '/' . $route->assemble($args, true); $type = $this->_controller->getEntity()->getAncestorType(); if ($type == Sitengine_Blog_Posts_Table::TYPE_GALLERY) { $title = $this->_controller->getTranslate()->translate('labelsViewformInsertPhotoTitle'); } else { $title = $this->_controller->getTranslate()->translate('labelsViewformInsertFileTitle'); } } #Sitengine_Debug::print_r($data); ######################################################################## #### ELEMENTS ######################################################################## if ($payloads->isMain()) { /* if( (!$data['id']) || # on insert (isset($data[Sitengine_Permiso::FIELD_UID]) && $data[Sitengine_Permiso::FIELD_UID]==$this->_controller->getPermiso()->getAuth()->getId()) || # owners ok #$this->_controller->getPermiso()->getUser()->hasSupervisorRights() || # supervisors ok #$this->_controller->getPermiso()->getUser()->hasModeratorRights() # moderators ok $this->_controller->getPermiso()->getDirectory()->userIsMember($this->_controller->getPermiso()->getAuth()->getId(), Sitengine_Permiso::GID_ADMINISTRATORS) ) { $n = Sitengine_Permiso::FIELD_UID; $e = new Sitengine_Form_Element($n, $data[$n]); $e->setClass('viewFormSelect'); $e->setId('viewForm'.$n); $users = $this->_controller->getPermiso()->getDirectory()->getAllUsers(); $elements[$n] = $e->getSelect($users); $n = Sitengine_Permiso::FIELD_GID; $e = new Sitengine_Form_Element($n, $data[$n]); $e->setClass('viewFormSelect'); $e->setId('viewForm'.$n); $groups = $this->_controller->getPermiso()->getDirectory()->getAllGroups(); $groups = array_merge($this->_controller->getTranslate()->translateGroup('fieldValsGid')->toArray(), $groups); $elements[$n] = $e->getSelect($groups); $n = Sitengine_Permiso::FIELD_RAG; $e = new Sitengine_Form_Element($n, '1'); $e->setClass('viewFormCheckbox'); $e->setId('viewForm'.$n); $elements[$n] = $e->getCheckbox($data[$n]); $n = Sitengine_Permiso::FIELD_RAW; $e = new Sitengine_Form_Element($n, '1'); $e->setClass('viewFormCheckbox'); $e->setId('viewForm'.$n); $elements[$n] = $e->getCheckbox($data[$n]); $n = Sitengine_Permiso::FIELD_UAG; $e = new Sitengine_Form_Element($n, '1'); $e->setClass('viewFormCheckbox'); $e->setId('viewForm'.$n); $elements[$n] = $e->getCheckbox($data[$n]); $n = Sitengine_Permiso::FIELD_UAW; $e = new Sitengine_Form_Element($n, '1'); $e->setClass('viewFormCheckbox'); $e->setId('viewForm'.$n); $elements[$n] = $e->getCheckbox($data[$n]); $n = Sitengine_Permiso::FIELD_DAG; $e = new Sitengine_Form_Element($n, '1'); $e->setClass('viewFormCheckbox'); $e->setId('viewForm'.$n); $elements[$n] = $e->getCheckbox($data[$n]); $n = Sitengine_Permiso::FIELD_DAW; $e = new Sitengine_Form_Element($n, '1'); $e->setClass('viewFormCheckbox'); $e->setId('viewForm'.$n); $elements[$n] = $e->getCheckbox($data[$n]); } */ $n = 'titleLang' . $transcripts->getDefaultIndex(); $e = new Sitengine_Form_Element($n, $data[$n]); $e->setClass('viewFormInput'); $e->setId('viewForm' . $n); $elements['title'] = $e->getText(40); $n = 'publish'; $e = new Sitengine_Form_Element($n, '1'); $e->setClass('viewFormCheckbox'); $e->setId('viewForm' . $n); $elements[$n] = $e->getCheckbox($data[$n]); $n = 'sorting'; $e = new Sitengine_Form_Element($n, $data[$n]); $e->setClass('viewFormInput'); $e->setId('viewForm' . $n); $elements[$n] = $e->getText(5); $n = 'file1Original'; $e = new Sitengine_Form_Element($n); $e->setClass('viewFormFile'); $e->setId('viewForm' . $n); $elements[$n] = $e->getFile(40); } $n = 'titleLang' . $payloads->getTranscriptIndex(); $e = new Sitengine_Form_Element($n, $data[$n]); $e->setClass('viewFormInput'); $e->setId('viewForm' . $n); $elements['title'] = $e->getText(40); #$n = 'markupLang'.$payloads->getTranscriptIndex(); #$elements['markup'] = $this->_makeTextarea($n, $data[$n]); $n = 'markupLang' . $payloads->getTranscriptIndex(); $e = new Sitengine_Form_Element($n, $data[$n]); $e->setClass('viewFormTextarea'); $e->setId('markupTextarea'); $elements['markup'] = $e->getTextarea(40, 10); ######################################################################## #### CONTENT PAYLOAD SECTION TITLE ######################################################################## $contentSectionTitle = $this->_controller->getTranslate()->translate('labelsViewformContentSectionTitleDefault'); if (sizeof($transcripts->get()) > 1) { if (!$payloads->isMain()) { $symbol = $payloads->getTranscriptSymbol(); } else { $symbol = $transcripts->getDefaultSymbol(); } $contentSectionTitle .= ' (' . $this->_controller->getTranslate()->translate('languages' . ucfirst($symbol)) . ')'; } ######################################################################## #### PAYLOAD NAV DATA ######################################################################## $payloadNav = array(); if ($this->_inputMode == Sitengine_Env::INPUTMODE_UPDATE) { $args = array(Sitengine_Env::PARAM_GREATANCESTORID => $this->_controller->getEntity()->getGreatAncestorSlug(), Sitengine_Env::PARAM_ANCESTORID => $this->_controller->getEntity()->getAncestorId(), Sitengine_Env::PARAM_ID => $stored['id']); $query = array(Sitengine_Env::PARAM_PAYLOAD_NAME => $payloads->getMainName()); $route = $this->_controller->getFrontController()->getRouter()->getRoute(Sitengine_Blog_Backend_Front::ROUTE_BLOGS_POSTS_FILES_SHARP); $uri = $this->_controller->getRequest()->getBasePath() . '/' . $route->assemble($args, true); $uri .= Sitengine_Controller_Request_Http::makeNameValueQuery($query); $payloadNav[$payloads->getMainName()] = array('uri' => $uri, 'label' => $this->_controller->getTranslate()->translate('labelsViewformPayloadNavTitleMain')); $count = 0; foreach ($transcripts->get() as $index => $symbol) { # skip default transcript because all fields are available in the overview if ($count) { $currentPayload = $payloads->getTranscriptNamePrefix() . '_' . $symbol; $args = array(Sitengine_Env::PARAM_GREATANCESTORID => $this->_controller->getEntity()->getGreatAncestorSlug(), Sitengine_Env::PARAM_ANCESTORID => $this->_controller->getEntity()->getAncestorId(), Sitengine_Env::PARAM_ID => $stored['id']); $query = array(Sitengine_Env::PARAM_PAYLOAD_NAME => $currentPayload); $route = $this->_controller->getFrontController()->getRouter()->getRoute(Sitengine_Blog_Backend_Front::ROUTE_BLOGS_POSTS_FILES_SHARP); $uri = $this->_controller->getRequest()->getBasePath() . '/' . $route->assemble($args, true); $uri .= Sitengine_Controller_Request_Http::makeNameValueQuery($query); if (sizeof($transcripts->get()) > 1) { $label = $this->_controller->getTranslate()->translate('languages' . ucfirst($symbol)); } else { $label = $this->_controller->getTranslate()->translate('labelsViewformContentSectionTitleDefault'); } $payloadNav[$currentPayload] = array('uri' => $uri, 'label' => $label); } $count++; } } ######################################################################## #### COLLECT ALL DATA ######################################################################## foreach ($hiddens as $k => $v) { $hiddens[$k] = Sitengine_Form_Element::getHidden($k, $v); } return array('payloadName' => $payloads->getName(), 'payloadIsMain' => $payloads->isMain(), 'payloadIsDefaultTranscript' => $payloads->isDefaultTranscript(), 'queryUpdate' => isset($queryUpdate) ? $queryUpdate : '', 'title' => $title, 'contentSectionTitle' => $contentSectionTitle, 'inputMode' => $this->_inputMode, 'hiddens' => implode('', $hiddens), 'submitUri' => $submitUri, 'ELEMENTS' => $elements, 'PAYLOADNAV' => $payloadNav, 'DATA' => $data); } catch (Exception $exception) { require_once 'Sitengine/Blog/Backend/Blogs/Posts/Files/Exception.php'; throw new Sitengine_Blog_Backend_Blogs_Posts_Files_Exception('form page error', $exception); } }
protected function _getMainSection() { try { $input = $this->_controller->getRequest()->getPost(null); #$valueSort = $this->_controller->getRequest()->get(Sitengine_Env::PARAM_SORT); #$valueOrder = $this->_controller->getRequest()->get(Sitengine_Env::PARAM_ORDER); #$valuePage = $this->_controller->getRequest()->get(Sitengine_Env::PARAM_PAGE); ######################################################################## #### FILTER INPUT ######################################################################## $fieldsNormal = array('id' => '', 'keyword' => '', 'description' => ''); foreach ($this->_controller->getTranscripts()->get() as $index => $symbol) { $fieldsNormal['titleLang' . $index] = ''; $fieldsNormal['metaKeywordsLang' . $index] = ''; $fieldsNormal['metaDescriptionLang' . $index] = ''; } $fieldsOnOff = array('locked' => 0); if ($this->_inputMode == Sitengine_Env::INPUTMODE_UPDATE) { require_once 'Sitengine/Form/TranscriptsPayloads.php'; $payloads = new Sitengine_Form_TranscriptsPayloads($this->_controller->getTranscripts()); $payloads->start($this->_controller->getRequest()->get(Sitengine_Env::PARAM_PAYLOAD_NAME)); $stored = $this->_controller->getEntity()->getData(); $data = Sitengine_Controller_Request_Http::filterUpdateDeprecated(sizeof($input), $input, $fieldsNormal, $fieldsOnOff, $stored); $data = array_merge($stored, $data); # set dates to timezone /* $name = 'cdate'; $date = new Zend_Date($stored[$name], Zend_Date::ISO_8601, $this->_controller->getLocale()); $date->setTimezone($this->_controller->getPreferences()->getTimezone()); $data[$name] = $date->get(Zend_Date::DATE_FULL).' '; $data[$name] .= $date->get(Zend_Date::TIME_FULL); */ /* $name = 'mdate'; $date = new Zend_Date($stored[$name], Zend_Date::ISO_8601, $this->_controller->getLocale()); $date->setTimezone($this->_controller->getPreferences()->getTimezone()); $data[$name] = $date->get(Zend_Date::DATE_LONG).' '; $data[$name] .= $date->get(Zend_Date::TIME_LONG); */ $hiddens = array(Sitengine_Env::PARAM_PAYLOAD_NAME => $payloads->getName(), Sitengine_Env::PARAM_MDATE => $stored['mdate']); $args = array(Sitengine_Env::PARAM_ID => $stored['id'], Sitengine_Env::PARAM_ACTION => Sitengine_Sitemap_Backend_Controller::ACTION_DOUPDATEPAGE); $route = $this->_controller->getFrontController()->getRouter()->getRoute(Sitengine_Sitemap_Backend_Front::ROUTE_INDEX); $submitUri = $this->_controller->getRequest()->getBasePath() . '/' . $route->assemble($args, true); $title = $this->_controller->getTranslate()->translate('labelsViewformUpdatePageTitle'); } else { require_once 'Sitengine/Form/TranscriptsPayloads.php'; $payloads = new Sitengine_Form_TranscriptsPayloads($this->_controller->getTranscripts()); $payloads->start(); $data = Sitengine_Controller_Request_Http::filterInsertDeprecated(sizeof($input), $input, $fieldsNormal, $fieldsOnOff); $gid = $this->_controller->getPermiso()->getDirectory()->getGroupId($this->_controller->getOwnerGroup()); $data[Sitengine_Permiso::FIELD_GID] = !is_null($gid) ? $gid : Sitengine_Permiso::GID_ADMINISTRATORS; $data[Sitengine_Permiso::FIELD_UID] = $this->_controller->getPermiso()->getAuth()->getId(); $hiddens = array(Sitengine_Env::PARAM_PAYLOAD_NAME => $payloads->getName()); $args = array(Sitengine_Env::PARAM_PARENTID => $this->_controller->getEntity()->getParentId(), Sitengine_Env::PARAM_ACTION => Sitengine_Sitemap_Backend_Controller::ACTION_DONEWPAGE); $route = $this->_controller->getFrontController()->getRouter()->getRoute(Sitengine_Sitemap_Backend_Front::ROUTE_INDEX); $submitUri = $this->_controller->getRequest()->getBasePath() . '/' . $route->assemble($args, true); $title = $this->_controller->getTranslate()->translate('labelsViewformNewPageTitle'); } #Sitengine_Debug::print_r($data); ######################################################################## #### ELEMENTS ######################################################################## if ($payloads->isMain()) { /* if( (!$data['id']) || # on insert (isset($data[Sitengine_Permiso::FIELD_UID]) && $data[Sitengine_Permiso::FIELD_UID]==$this->_controller->getPermiso()->getAuth()->getId()) || # owners ok #$this->_controller->getPermiso()->getUser()->hasSupervisorRights() || # supervisors ok #$this->_controller->getPermiso()->getUser()->hasModeratorRights() # moderators ok $this->_controller->getPermiso()->getDirectory()->userIsMember($this->_controller->getPermiso()->getAuth()->getId(), Sitengine_Permiso::GID_ADMINISTRATORS) ) { $n = Sitengine_Permiso::FIELD_UID; $e = new Sitengine_Form_Element($n, $data[$n]); $e->setClass('viewFormSelect'); $e->setId('viewForm'.$n); $users = $this->_controller->getPermiso()->getDirectory()->getAllUsers(); $elements[$n] = $e->getSelect($users); $n = Sitengine_Permiso::FIELD_GID; $e = new Sitengine_Form_Element($n, $data[$n]); $e->setClass('viewFormSelect'); $e->setId('viewForm'.$n); $groups = $this->_controller->getPermiso()->getDirectory()->getAllGroups(); $groups = array_merge($this->_controller->getTranslate()->translateGroup('fieldValsGid')->toArray(), $groups); $elements[$n] = $e->getSelect($groups); $n = Sitengine_Permiso::FIELD_RAG; $e = new Sitengine_Form_Element($n, '1'); $e->setClass('viewFormCheckbox'); $e->setId('viewForm'.$n); $elements[$n] = $e->getCheckbox($data[$n]); $n = Sitengine_Permiso::FIELD_RAW; $e = new Sitengine_Form_Element($n, '1'); $e->setClass('viewFormCheckbox'); $e->setId('viewForm'.$n); $elements[$n] = $e->getCheckbox($data[$n]); $n = Sitengine_Permiso::FIELD_UAG; $e = new Sitengine_Form_Element($n, '1'); $e->setClass('viewFormCheckbox'); $e->setId('viewForm'.$n); $elements[$n] = $e->getCheckbox($data[$n]); $n = Sitengine_Permiso::FIELD_UAW; $e = new Sitengine_Form_Element($n, '1'); $e->setClass('viewFormCheckbox'); $e->setId('viewForm'.$n); $elements[$n] = $e->getCheckbox($data[$n]); $n = Sitengine_Permiso::FIELD_DAG; $e = new Sitengine_Form_Element($n, '1'); $e->setClass('viewFormCheckbox'); $e->setId('viewForm'.$n); $elements[$n] = $e->getCheckbox($data[$n]); $n = Sitengine_Permiso::FIELD_DAW; $e = new Sitengine_Form_Element($n, '1'); $e->setClass('viewFormCheckbox'); $e->setId('viewForm'.$n); $elements[$n] = $e->getCheckbox($data[$n]); } */ $n = 'locked'; $e = new Sitengine_Form_Element($n, '1'); $e->setClass('viewFormCheckbox'); $e->setId('viewForm' . $n); $elements[$n] = $e->getCheckbox($data[$n]); /* $n = 'enabled'; $e = new Sitengine_Form_Element($n, '1'); $e->setClass('viewFormCheckbox'); $e->setId('viewForm'.$n); $elements[$n] = $e->getCheckbox($data[$n]); */ $n = 'keyword'; $e = new Sitengine_Form_Element($n, $data[$n]); $e->setClass('viewFormInput'); $e->setId('viewForm' . $n); $elements[$n] = $e->getText(40); /* $n = 'metaKeywords'; $e = new Sitengine_Form_Element($n, $data[$n]); $e->setClass('viewFormTextarea'); $e->setId('viewForm'.$n); $elements[$n] = $e->getTextarea(40, 3); $n = 'metaDescription'; $e = new Sitengine_Form_Element($n, $data[$n]); $e->setClass('viewFormTextarea'); $e->setId('viewForm'.$n); $elements[$n] = $e->getTextarea(40, 3); */ $n = 'description'; $e = new Sitengine_Form_Element($n, $data[$n]); $e->setClass('viewFormInput'); $e->setId('viewForm' . $n); $elements[$n] = $e->getTextarea(60, 10); } else { $n = 'titleLang' . $payloads->getTranscriptIndex(); $e = new Sitengine_Form_Element($n, $data[$n]); $e->setClass('viewFormInput'); $e->setId('viewForm' . $n); $elements['title'] = $e->getText(40); $n = 'metaKeywordsLang' . $payloads->getTranscriptIndex(); $e = new Sitengine_Form_Element($n, $data[$n]); $e->setClass('viewFormTextarea'); $e->setId('viewForm' . $n); $elements['metaKeywords'] = $e->getTextarea(40, 3); $n = 'metaDescriptionLang' . $payloads->getTranscriptIndex(); $e = new Sitengine_Form_Element($n, $data[$n]); $e->setClass('viewFormTextarea'); $e->setId('viewForm' . $n); $elements['metaDescription'] = $e->getTextarea(40, 3); } ######################################################################## #### CONTENT PAYLOAD SECTION TITLE ######################################################################## $contentSectionTitle = $this->_controller->getTranslate()->translate('labelsViewformContentSectionTitleDefault'); $contentSectionTitle = 'Meta Info'; if (sizeof($this->_controller->getTranscripts()->get()) > 1) { if (!$payloads->isMain()) { $symbol = $payloads->getTranscriptSymbol(); } else { $symbol = $this->_controller->getTranscripts()->getDefaultSymbol(); } $contentSectionTitle .= ' (' . $this->_controller->getTranslate()->translate('languages' . ucfirst($symbol)) . ')'; } ######################################################################## #### PAYLOAD NAV DATA ######################################################################## $payloadNav = array(); if ($this->_inputMode == Sitengine_Env::INPUTMODE_UPDATE) { $args = array(Sitengine_Env::PARAM_ACTION => Sitengine_Sitemap_Backend_Controller::ACTION_UPDATEPAGE, Sitengine_Env::PARAM_ID => $stored['id'], Sitengine_Env::PARAM_PAYLOAD_NAME => $payloads->getMainName()); $route = $this->_controller->getFrontController()->getRouter()->getRoute(Sitengine_Sitemap_Backend_Front::ROUTE_INDEX); $uri = $this->_controller->getRequest()->getBasePath() . '/' . $route->assemble($args, true); $payloadNav[$payloads->getMainName()] = array('uri' => $uri, 'label' => $this->_controller->getTranslate()->translate('labelsViewformPayloadNavTitleMain')); foreach ($this->_controller->getTranscripts()->get() as $index => $symbol) { $currentPayload = $payloads->getTranscriptNamePrefix() . '_' . $symbol; $args = array(Sitengine_Env::PARAM_ACTION => Sitengine_Sitemap_Backend_Controller::ACTION_UPDATEPAGE, Sitengine_Env::PARAM_ID => $stored['id'], Sitengine_Env::PARAM_PAYLOAD_NAME => $currentPayload); $route = $this->_controller->getFrontController()->getRouter()->getRoute(Sitengine_Sitemap_Backend_Front::ROUTE_INDEX); $uri = $this->_controller->getRequest()->getBasePath() . '/' . $route->assemble($args, true); if (sizeof($this->_controller->getTranscripts()->get()) > 1) { $label = 'Meta Info (' . $this->_controller->getTranslate()->translate('languages' . ucfirst($symbol)) . ')'; } else { $label = 'Meta Info'; #.$this->_controller->getTranslate()->translate('labelsViewformContentSectionTitleDefault'); } $payloadNav[$currentPayload] = array('uri' => $uri, 'label' => $label); } } ######################################################################## #### COLLECT ALL DATA ######################################################################## foreach ($hiddens as $k => $v) { $hiddens[$k] = Sitengine_Form_Element::getHidden($k, $v); } return array('payloadName' => $payloads->getName(), 'payloadIsMain' => $payloads->isMain(), 'payloadIsDefaultTranscript' => $payloads->isDefaultTranscript(), 'title' => $title, 'contentSectionTitle' => $contentSectionTitle, 'inputMode' => $this->_inputMode, 'hiddens' => implode('', $hiddens), 'submitUri' => $submitUri, 'ELEMENTS' => $elements, 'PAYLOADNAV' => $payloadNav, 'DATA' => $data); } catch (Exception $exception) { require_once 'Sitengine/Sitemap/Backend/Exception.php'; throw new Sitengine_Sitemap_Backend_Exception('form page error', $exception); } }