Пример #1
0
 protected function _getMainSection()
 {
     try {
         $valuePage = $this->_controller->getRequest()->get(Sitengine_Env::PARAM_PAGE);
         $table = $this->_controller->getFrontController()->getBlogPackage()->getFilesTable();
         $table->setTranscript($this->_controller->getPreferences()->getTranscript());
         $filter = $table->getFilterInstance($this->_controller->getRequest(), array('find' => Sitengine_Blog_Backend_Blogs_Posts_Files_Controller::PARAM_FILTER_BY_FIND, 'type' => Sitengine_Blog_Backend_Blogs_Posts_Files_Controller::PARAM_FILTER_BY_TYPE, 'reset' => Sitengine_Blog_Backend_Blogs_Posts_Files_Controller::PARAM_FILTER_RESET), $this->_controller->getNamespace());
         $sorting = $table->getSortingInstance($this->_controller->getRequest()->get(Sitengine_Env::PARAM_SORT), $this->_controller->getRequest()->get(Sitengine_Env::PARAM_ORDER));
         ########################################################################
         #### SETTINGS
         ########################################################################
         $settingsIsActive = false;
         $settingsElements = array();
         ### transcript element ###
         $transcripts = $table->getTranscripts();
         $transcripts->setLanguage($this->_controller->getPreferences()->getTranscript());
         if (!$transcripts->isDefault()) {
             $settingsIsActive = true;
         }
         # set html input element
         $languages = array();
         foreach ($transcripts->get() as $symbol) {
             $languages[$symbol] = $this->_controller->getTranslate()->translate('languages' . ucfirst($symbol));
         }
         $e = new Sitengine_Form_Element(Sitengine_Env::PARAM_TRANSCRIPT, $transcripts->getSymbol());
         $e->setId('settings' . Sitengine_Env::PARAM_TRANSCRIPT);
         $e->setClass('settingsSelect');
         $settingsElements[Sitengine_Env::PARAM_TRANSCRIPT] = $e->getSelect($languages);
         ### ipp element ###
         $defaultIpp = 20;
         $valueIpp = $this->_controller->getPreferences()->getItemsPerPage();
         $valueIpp = is_numeric($valueIpp) ? $valueIpp : $defaultIpp;
         $valueIpp = $valueIpp <= 100 && $valueIpp >= 1 ? $valueIpp : $defaultIpp;
         # set html input element
         $ippValues = array('' => $this->_controller->getTranslate()->translate('labelsSettingsSectionItemsPerPage'), 5 => 5, 10 => 10, 20 => 20, 50 => 50, 100 => 100);
         $e = new Sitengine_Form_Element(Sitengine_Env::PARAM_IPP, $valueIpp);
         $e->setId('settings' . Sitengine_Env::PARAM_IPP);
         $e->setClass('settingsSelect');
         $settingsElements[Sitengine_Env::PARAM_IPP] = $e->getSelect($ippValues);
         $hiddens = array(Sitengine_Env::PARAM_SORT => $sorting->getActiveRule(), Sitengine_Env::PARAM_ORDER => $sorting->getActiveOrder());
         foreach ($hiddens as $k => $v) {
             $hiddens[$k] = Sitengine_Form_Element::getHidden($k, $v);
         }
         $settingsData = array('isActive' => $settingsIsActive, 'hiddens' => implode('', $hiddens), 'ELEMENTS' => $settingsElements);
         ########################################################################
         #### FILTER
         ########################################################################
         /*
         $users = $this->_controller->getPermiso()->getDirectory()->getAllUsers();
         $values = array_merge($this->_controller->getTranslate()->translateGroup('fieldValsFilterByUid')->toArray(), $users);
         $e = new Sitengine_Form_Element(Sitengine_Blog_Backend_Blogs_Posts_Files_Controller::PARAM_FILTER_BY_UID, $filter->getVal(Sitengine_Blog_Backend_Blogs_Posts_Files_Controller::PARAM_FILTER_BY_UID));
         $e->setId('filter'.Sitengine_Blog_Backend_Blogs_Posts_Files_Controller::PARAM_FILTER_BY_UID);
         $e->setClass('filterSelect');
         $filter->setElement(Sitengine_Blog_Backend_Blogs_Posts_Files_Controller::PARAM_FILTER_BY_UID, $e->getSelect($values));
         
         $groups = $this->_controller->getPermiso()->getDirectory()->getAllGroups();
         $values = array_merge($this->_controller->getTranslate()->translateGroup('fieldValsFilterByGid')->toArray(), $groups);
         $e = new Sitengine_Form_Element(Sitengine_Blog_Backend_Blogs_Posts_Files_Controller::PARAM_FILTER_BY_GID, $filter->getVal(Sitengine_Blog_Backend_Blogs_Posts_Files_Controller::PARAM_FILTER_BY_GID));
         $e->setId('filter'.Sitengine_Blog_Backend_Blogs_Posts_Files_Controller::PARAM_FILTER_BY_GID);
         $e->setClass('filterSelect');
         $filter->setElement(Sitengine_Blog_Backend_Blogs_Posts_Files_Controller::PARAM_FILTER_BY_GID, $e->getSelect($values));
         */
         $e = new Sitengine_Form_Element(Sitengine_Blog_Backend_Blogs_Posts_Files_Controller::PARAM_FILTER_BY_FIND, $filter->getVal(Sitengine_Blog_Backend_Blogs_Posts_Files_Controller::PARAM_FILTER_BY_FIND));
         $e->setId('filter' . Sitengine_Blog_Backend_Blogs_Posts_Files_Controller::PARAM_FILTER_BY_FIND);
         $e->setClass('filterText');
         $filter->setElement(Sitengine_Blog_Backend_Blogs_Posts_Files_Controller::PARAM_FILTER_BY_FIND, $e->getText(20));
         $hiddens = array(Sitengine_Env::PARAM_SORT => $sorting->getActiveRule(), Sitengine_Env::PARAM_ORDER => $sorting->getActiveOrder());
         foreach ($hiddens as $k => $v) {
             $hiddens[$k] = Sitengine_Form_Element::getHidden($k, $v);
         }
         $args = array(Sitengine_Env::PARAM_GREATANCESTORID => $this->_controller->getEntity()->getGreatAncestorSlug(), Sitengine_Env::PARAM_ANCESTORID => $this->_controller->getEntity()->getAncestorId());
         $query = array(Sitengine_Env::PARAM_SORT => $sorting->getActiveRule(), Sitengine_Env::PARAM_ORDER => $sorting->getActiveOrder(), Sitengine_Blog_Backend_Blogs_Posts_Files_Controller::PARAM_FILTER_RESET => 1);
         $route = $this->_controller->getFrontController()->getRouter()->getRoute(Sitengine_Blog_Backend_Front::ROUTE_BLOGS_POSTS_FILES);
         $uriReset = $this->_controller->getRequest()->getBasePath() . '/' . $route->assemble($args, true);
         $uriReset .= Sitengine_Controller_Request_Http::makeNameValueQuery($query);
         $filterData = array('isActive' => $filter->isActive(), 'uriReset' => $uriReset, 'hiddens' => implode('', $hiddens), 'ELEMENTS' => $filter->getElements());
         ########################################################################
         #### SORTING
         ########################################################################
         $queries = array();
         foreach ($sorting->getOrdering() as $field => $order) {
             $args = array(Sitengine_Env::PARAM_GREATANCESTORID => $this->_controller->getEntity()->getGreatAncestorSlug(), Sitengine_Env::PARAM_ANCESTORID => $this->_controller->getEntity()->getAncestorId());
             $query = array(Sitengine_Env::PARAM_SORT => $field, Sitengine_Env::PARAM_ORDER => $order);
             $route = $this->_controller->getFrontController()->getRouter()->getRoute(Sitengine_Blog_Backend_Front::ROUTE_BLOGS_POSTS_FILES);
             $queries[$field] = $this->_controller->getRequest()->getBasePath() . '/' . $route->assemble($args, true);
             $queries[$field] .= Sitengine_Controller_Request_Http::makeNameValueQuery($query);
         }
         $sortingData = array('QUERIES' => $queries, 'COLUMNS' => $sorting->getColumns());
         ########################################################################
         #### PAGER
         ########################################################################
         $pager = new Sitengine_Grid_Pager($valuePage, $valueIpp);
         ########################################################################
         #### LISTQUERY
         ########################################################################
         $name = $this->_controller->getFrontController()->getBlogPackage()->getFilesTableName();
         $whereClauses = array($this->_controller->getDatabase()->quoteInto('parentId = ?', $this->_controller->getEntity()->getAncestorId()), $this->_controller->getPermiso()->getDac()->getReadAccessSql($this->_controller->getFrontController()->getBlogPackage()->getAuthorizedGroups(), $name, false), $filter->getSql(''));
         $select = $table->select()->order($sorting->getClause())->limit($valueIpp, $pager->getOffset());
         foreach ($whereClauses as $clause) {
             if ($clause) {
                 $select->where($clause);
             }
         }
         $items = $table->fetchAll($select);
         # if current page is out of bounds - go to beginning of list
         if (!$items->count() && $pager->getCurrPage() > 1) {
             $pager = new Sitengine_Grid_Pager(1, $valueIpp);
             $select = $table->select()->order($sorting->getClause())->limit($valueIpp, 0);
             foreach ($whereClauses as $clause) {
                 if ($clause) {
                     $select->where($clause);
                 }
             }
             $items = $table->fetchAll($select);
         }
         # count total number of records
         $select = $table->select()->from($table, array('COUNT(*) AS count'));
         foreach ($whereClauses as $clause) {
             if ($clause) {
                 $select->where($clause);
             }
         }
         $count = $table->fetchRow($select);
         $pager->calculate($count->count);
         ########################################################################
         #### LISTDATA
         ########################################################################
         $markedRows = $this->_controller->getMarkedRows();
         $list = array();
         foreach ($items as $item) {
             $row = $table->complementRow($item);
             # row selector checkbox
             $p = 'SELECTROWITEM' . $row['id'];
             $s = sizeof($markedRows) && isset($markedRows[$row['id']]) ? $this->_controller->getRequest()->getPost($p) : 0;
             $e = new Sitengine_Form_Element($p, 1);
             $e->setClass('listformCheckbox');
             $row['rowSelectCheckbox'] = $e->getCheckbox($s);
             $n = 'sorting';
             $p = 'UPDATEROWITEM' . $n . 'ITEMID' . $row['id'];
             $h = 'UPDATEROWITEMCURRENT' . $n . 'ITEMID' . $row['id'];
             $v = sizeof($markedRows) && isset($markedRows[$row['id']]) ? $this->_controller->getRequest()->getPost($p) : $row[$n];
             $e = new Sitengine_Form_Element($p, $v);
             $e->setClass('listformText');
             $sort = $e->getText(5);
             $sort .= Sitengine_Form_Element::getHidden($h, $row[$n]);
             $n = 'publish';
             $p = 'UPDATEROWITEM' . $n . 'ITEMID' . $row['id'];
             $h = 'UPDATEROWITEMCURRENT' . $n . 'ITEMID' . $row['id'];
             $s = sizeof($markedRows) && isset($markedRows[$row['id']]) ? $this->_controller->getRequest()->getPost($p) : $row[$n];
             $e = new Sitengine_Form_Element($p, 1);
             $e->setClass('listformCheckbox');
             $publish = $e->getCheckbox($s);
             $publish .= Sitengine_Form_Element::getHidden($h, $row[$n]);
             # uris
             $args = array(Sitengine_Env::PARAM_GREATANCESTORID => $this->_controller->getEntity()->getGreatAncestorSlug(), Sitengine_Env::PARAM_ANCESTORID => $this->_controller->getEntity()->getAncestorId(), Sitengine_Env::PARAM_ID => $row['id']);
             $route = $this->_controller->getFrontController()->getRouter()->getRoute(Sitengine_Blog_Backend_Front::ROUTE_BLOGS_POSTS_FILES_SHARP);
             $uriUpdate = $this->_controller->getRequest()->getBasePath() . '/' . $route->assemble($args, true);
             $row['isMarked'] = isset($markedRows[$row['id']]) ? $markedRows[$row['id']] : 0;
             $row['sortingText'] = $sort;
             $row['publishCheckbox'] = $publish;
             $row['uriUpdate'] = $uriUpdate;
             $name = 'cdate';
             $date = new Zend_Date($row[$name], Zend_Date::ISO_8601, $this->_controller->getLocale());
             $date->setTimezone($this->_controller->getPreferences()->getTimezone());
             $row[$name] = $date->get(Zend_Date::DATE_LONG, $this->_controller->getLocale()) . ' ';
             $row[$name] .= $date->get(Zend_Date::TIME_LONG, $this->_controller->getLocale());
             $list[] = $row;
         }
         #Sitengine_Debug::print_r($list);
         ########################################################################
         #### PAGER DATA
         ########################################################################
         $hiddens = array(Sitengine_Env::PARAM_SORT => $sorting->getActiveRule(), Sitengine_Env::PARAM_ORDER => $sorting->getActiveOrder());
         foreach ($hiddens as $k => $v) {
             $hiddens[$k] = Sitengine_Form_Element::getHidden($k, $v);
         }
         $args = array(Sitengine_Env::PARAM_GREATANCESTORID => $this->_controller->getEntity()->getGreatAncestorSlug(), Sitengine_Env::PARAM_ANCESTORID => $this->_controller->getEntity()->getAncestorId());
         $query = array(Sitengine_Env::PARAM_SORT => $sorting->getActiveRule(), Sitengine_Env::PARAM_ORDER => $sorting->getActiveOrder(), Sitengine_Env::PARAM_PAGE => $pager->getPrevPage());
         $route = $this->_controller->getFrontController()->getRouter()->getRoute(Sitengine_Blog_Backend_Front::ROUTE_BLOGS_POSTS_FILES);
         $uriPrevPage = $this->_controller->getRequest()->getBasePath() . '/' . $route->assemble($args, true);
         $uriPrevPage .= Sitengine_Controller_Request_Http::makeNameValueQuery($query);
         $args = array(Sitengine_Env::PARAM_GREATANCESTORID => $this->_controller->getEntity()->getGreatAncestorSlug(), Sitengine_Env::PARAM_ANCESTORID => $this->_controller->getEntity()->getAncestorId());
         $query = array(Sitengine_Env::PARAM_SORT => $sorting->getActiveRule(), Sitengine_Env::PARAM_ORDER => $sorting->getActiveOrder(), Sitengine_Env::PARAM_PAGE => $pager->getNextPage());
         $route = $this->_controller->getFrontController()->getRouter()->getRoute(Sitengine_Blog_Backend_Front::ROUTE_BLOGS_POSTS_FILES);
         $uriNextPage = $this->_controller->getRequest()->getBasePath() . '/' . $route->assemble($args, true);
         $uriNextPage .= Sitengine_Controller_Request_Http::makeNameValueQuery($query);
         $currPageInput = new Sitengine_Form_Element(Sitengine_Env::PARAM_PAGE, $pager->getCurrPage());
         $currPageInput->setClass('pagerInput');
         $pagerData = array('hiddens' => implode('', $hiddens), 'currPageInput' => $currPageInput->getText(2), 'currPage' => $pager->getCurrPage(), 'nextPage' => $pager->getNextPage(), 'prevPage' => $pager->getPrevPage(), 'numPages' => $pager->getNumPages(), 'numItems' => $pager->getNumItems(), 'firstItem' => $pager->getFirstItem(), 'lastItem' => $pager->getLastItem(), 'uriPrevPage' => $uriPrevPage, 'uriNextPage' => $uriNextPage);
         ########################################################################
         #### URIS
         ########################################################################
         $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_BATCH);
         $uriDoBatchDelete = $this->_controller->getRequest()->getBasePath() . '/' . $route->assemble($args, true);
         $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_BATCH);
         $uriDoBatchUpdate = $this->_controller->getRequest()->getBasePath() . '/' . $route->assemble($args, true);
         $uris = array('submitDoBatchDelete' => $uriDoBatchDelete, 'submitDoBatchUpdate' => $uriDoBatchUpdate);
         ########################################################################
         #### METHODS
         ########################################################################
         $methods = array('doBatchDelete' => Sitengine_Env::METHOD_DELETE, 'doBatchUpdate' => Sitengine_Env::METHOD_PUT);
         ########################################################################
         #### COLLECT ALL DATA
         ########################################################################
         $hiddens = array(Sitengine_Env::PARAM_METHOD => '', Sitengine_Env::PARAM_PAGE => $valuePage, Sitengine_Env::PARAM_SORT => $sorting->getActiveRule(), Sitengine_Env::PARAM_ORDER => $sorting->getActiveOrder());
         foreach ($hiddens as $k => $v) {
             $hiddens[$k] = Sitengine_Form_Element::getHidden($k, $v);
         }
         $type = $this->_controller->getEntity()->getAncestorType();
         if ($type == Sitengine_Blog_Posts_Table::TYPE_GALLERY) {
             $title = $this->_controller->getTranslate()->translate('labelsListformPhotoTitle');
         } else {
             $title = $this->_controller->getTranslate()->translate('labelsListformFileTitle');
         }
         return array('hiddens' => implode('', $hiddens), 'title' => $title, 'URIS' => $uris, 'METHODS' => $methods, 'FILTER' => $filterData, 'SETTINGS' => $settingsData, 'SORTING' => $sortingData, 'DATA' => $list, 'PAGER' => $pagerData);
     } catch (Exception $exception) {
         require_once 'Sitengine/Blog/Backend/Blogs/Posts/Files/Exception.php';
         throw new Sitengine_Blog_Backend_Blogs_Posts_Files_Exception('list page error', $exception);
     }
 }
Пример #2
0
 protected function _getMainSection()
 {
     try {
         require_once 'Sitengine/Form/Element.php';
         $valuePage = $this->_controller->getRequest()->get(Sitengine_Env::PARAM_PAGE);
         $table = $this->_controller->getFrontController()->getProtoPackage()->getGoodiesTable();
         $table->setTranscript($this->_controller->getPreferences()->getTranscript());
         $sorting = $table->getSortingInstance($this->_controller->getRequest()->get(Sitengine_Env::PARAM_SORT), $this->_controller->getRequest()->get(Sitengine_Env::PARAM_ORDER));
         ########################################################################
         #### SETTINGS
         ########################################################################
         $settingsIsActive = false;
         ### transcript ###
         $transcripts = $table->getTranscripts();
         $transcripts->setLanguage($this->_controller->getPreferences()->getTranscript());
         if (!$transcripts->isDefault()) {
             $settingsIsActive = true;
         }
         $languages = array();
         foreach ($transcripts->get() as $symbol) {
             $languages[$symbol] = $this->_controller->getTranslate()->translate('languages' . ucfirst($symbol));
         }
         ### ipp ###
         $defaultIpp = 20;
         $valueIpp = $this->_controller->getPreferences()->getItemsPerPage();
         $valueIpp = is_numeric($valueIpp) ? $valueIpp : $defaultIpp;
         $valueIpp = $valueIpp <= 100 && $valueIpp >= 1 ? $valueIpp : $defaultIpp;
         $ippValues = array('' => $this->_controller->getTranslate()->translate('indexViewSettingsSectionItemsPerPage'), 5 => 5, 10 => 10, 20 => 20, 50 => 50, 100 => 100);
         $hiddens = array(Sitengine_Env::PARAM_SORT => $sorting->getActiveRule(), Sitengine_Env::PARAM_ORDER => $sorting->getActiveOrder());
         foreach ($hiddens as $k => $v) {
             $hiddens[$k] = Sitengine_Form_Element::getHidden($k, $v);
         }
         $settingsData = array('isActive' => $settingsIsActive, 'hiddens' => implode('', $hiddens), 'TRANSCRIPTS' => $languages, 'IPPS' => $ippValues, Sitengine_Env::PARAM_TRANSCRIPT => $transcripts->getSymbol(), Sitengine_Env::PARAM_IPP => $valueIpp);
         ########################################################################
         #### FILTER
         ########################################################################
         $filter = $table->getFilterInstance($this->_controller->getRequest(), array('uid' => Sitengine_Proto_Backend_Goodies_Controller::PARAM_FILTER_BY_UID, 'gid' => Sitengine_Proto_Backend_Goodies_Controller::PARAM_FILTER_BY_GID, 'type' => Sitengine_Proto_Backend_Goodies_Controller::PARAM_FILTER_BY_TYPE, 'find' => Sitengine_Proto_Backend_Goodies_Controller::PARAM_FILTER_BY_FIND, 'reset' => Sitengine_Proto_Backend_Goodies_Controller::PARAM_FILTER_RESET), $this->_controller->getNamespace());
         $types = $this->_controller->getTranslate()->translateGroup('fieldValsFilterByType')->toArray();
         $users = $this->_controller->getPermiso()->getDirectory()->getAllUsers();
         $users = array_merge($this->_controller->getTranslate()->translateGroup('fieldValsFilterByUid')->toArray(), $users);
         $groups = $this->_controller->getPermiso()->getDirectory()->getAllGroups();
         $groups = array_merge($this->_controller->getTranslate()->translateGroup('fieldValsFilterByGid')->toArray(), $groups);
         $hiddens = array(Sitengine_Env::PARAM_SORT => $sorting->getActiveRule(), Sitengine_Env::PARAM_ORDER => $sorting->getActiveOrder());
         foreach ($hiddens as $k => $v) {
             $hiddens[$k] = Sitengine_Form_Element::getHidden($k, $v);
         }
         $query = array(Sitengine_Env::PARAM_SORT => $sorting->getActiveRule(), Sitengine_Env::PARAM_ORDER => $sorting->getActiveOrder(), Sitengine_Proto_Backend_Goodies_Controller::PARAM_FILTER_RESET => 1);
         $route = $this->_controller->getFrontController()->getRouter()->getRoute(Sitengine_Proto_Backend_Front::ROUTE_GOODIES);
         $uriReset = $this->_controller->getRequest()->getBasePath() . '/' . $route->assemble();
         $uriReset .= Sitengine_Controller_Request_Http::makeNameValueQuery($query);
         $filterData = array('isActive' => $filter->isActive(), 'uriReset' => $uriReset, 'hiddens' => implode('', $hiddens), 'DATA' => $filter->getData(), 'TYPES' => $types, 'USERS' => $users, 'GROUPS' => $groups);
         ########################################################################
         #### SORTING
         ########################################################################
         $queries = array();
         foreach ($sorting->getOrdering() as $field => $order) {
             $query = array(Sitengine_Env::PARAM_SORT => $field, Sitengine_Env::PARAM_ORDER => $order);
             $route = $this->_controller->getFrontController()->getRouter()->getRoute(Sitengine_Proto_Backend_Front::ROUTE_GOODIES);
             $queries[$field] = $this->_controller->getRequest()->getBasePath() . '/' . $route->assemble();
             $queries[$field] .= Sitengine_Controller_Request_Http::makeNameValueQuery($query);
         }
         $sortingData = array('QUERIES' => $queries, 'COLUMNS' => $sorting->getColumns());
         ########################################################################
         #### PAGER
         ########################################################################
         require_once 'Sitengine/Grid/Pager.php';
         $pager = new Sitengine_Grid_Pager($valuePage, $valueIpp);
         ########################################################################
         #### LISTQUERY
         ########################################################################
         $name = $this->_controller->getFrontController()->getProtoPackage()->getGoodiesTableName();
         $whereClauses = array($this->_controller->getPermiso()->getDac()->getReadAccessSql($this->_controller->getFrontController()->getProtoPackage()->getAuthorizedGroups(), $name, false), $filter->getSql(''));
         $select = $table->select()->order($sorting->getClause())->limit($valueIpp, $pager->getOffset());
         foreach ($whereClauses as $clause) {
             if ($clause) {
                 $select->where($clause);
             }
         }
         $items = $table->fetchAll($select);
         # if current page is out of bounds - go to beginning of list
         if (!$items->count() && $pager->getCurrPage() > 1) {
             $pager = new Sitengine_Grid_Pager(1, $valueIpp);
             $select = $table->select()->order($sorting->getClause())->limit($valueIpp, 0);
             foreach ($whereClauses as $clause) {
                 if ($clause) {
                     $select->where($clause);
                 }
             }
             $items = $table->fetchAll($select);
         }
         # count total number of records
         $select = $table->select()->from($table, array('COUNT(*) AS count'));
         foreach ($whereClauses as $clause) {
             if ($clause) {
                 $select->where($clause);
             }
         }
         $count = $table->fetchRow($select);
         $pager->calculate($count->count);
         ########################################################################
         #### LISTDATA
         ########################################################################
         $markedRows = $this->_controller->getMarkedRows();
         $list = array();
         foreach ($items as $item) {
             $row = $table->complementRow($item);
             #Sitengine_Debug::print_r($row);
             # row selector checkbox
             $row['rowSelectCheckbox'] = array();
             if (!$row['locked']) {
                 $name = 'SELECTROWITEM' . $row['id'];
                 $row['rowSelectCheckbox'] = array('name' => $name, 'checked' => sizeof($markedRows) && isset($markedRows[$row['id']]) ? $this->_controller->getRequest()->getPost($name) : 0);
             }
             $n = 'sorting';
             $name = 'UPDATEROWITEM' . $n . 'ITEMID' . $row['id'];
             $current = 'UPDATEROWITEMCURRENT' . $n . 'ITEMID' . $row['id'];
             $row['sortingText'] = array('name' => $name, 'value' => sizeof($markedRows) && isset($markedRows[$row['id']]) ? $this->_controller->getRequest()->getPost($name) : $row[$n], 'current' => Sitengine_Form_Element::getHidden($current, $row[$n]));
             $n = 'displayThis';
             $name = 'UPDATEROWITEM' . $n . 'ITEMID' . $row['id'];
             $current = 'UPDATEROWITEMCURRENT' . $n . 'ITEMID' . $row['id'];
             $row['displayThisSelect'] = array('name' => $name, 'value' => sizeof($markedRows) && isset($markedRows[$row['id']]) ? $this->_controller->getRequest()->getPost($name) : $row[$n], 'OPTIONS' => $this->_controller->getTranslate()->translateGroup('fieldValsDisplayThis')->toArray(), 'current' => Sitengine_Form_Element::getHidden($current, $row[$n]));
             $n = 'locked';
             $name = 'UPDATEROWITEM' . $n . 'ITEMID' . $row['id'];
             $current = 'UPDATEROWITEMCURRENT' . $n . 'ITEMID' . $row['id'];
             $row['lockedCheckbox'] = array('name' => $name, 'checked' => sizeof($markedRows) && isset($markedRows[$row['id']]) ? $this->_controller->getRequest()->getPost($name) : $row[$n], 'current' => Sitengine_Form_Element::getHidden($current, $row[$n]));
             $n = 'publish';
             $name = 'UPDATEROWITEM' . $n . 'ITEMID' . $row['id'];
             $current = 'UPDATEROWITEMCURRENT' . $n . 'ITEMID' . $row['id'];
             $row['publishCheckbox'] = array('name' => $name, 'checked' => sizeof($markedRows) && isset($markedRows[$row['id']]) ? $this->_controller->getRequest()->getPost($name) : $row[$n], 'current' => Sitengine_Form_Element::getHidden($current, $row[$n]));
             # uris
             $args = array(Sitengine_Env::PARAM_ID => $row['id']);
             $route = $this->_controller->getFrontController()->getRouter()->getRoute(Sitengine_Proto_Backend_Front::ROUTE_GOODIES_SHARP);
             $row['uriUpdate'] = $this->_controller->getRequest()->getBasePath() . '/' . $route->assemble($args, true);
             $args = array(Sitengine_Env::PARAM_ANCESTORID => $row['id']);
             $route = $this->_controller->getFrontController()->getRouter()->getRoute(Sitengine_Proto_Backend_Front::ROUTE_GOODIES_SHOULDIES);
             $row['uriShouldyIndex'] = $this->_controller->getRequest()->getBasePath() . '/' . $route->assemble($args, true);
             $row['isMarked'] = isset($markedRows[$row['id']]) ? $markedRows[$row['id']] : 0;
             $row['shouldyCount'] = $this->_controller->getViewHelper()->countShouldies($row['id']);
             $list[] = $row;
         }
         ########################################################################
         #### PAGER DATA
         ########################################################################
         $hiddens = array(Sitengine_Env::PARAM_SORT => $sorting->getActiveRule(), Sitengine_Env::PARAM_ORDER => $sorting->getActiveOrder());
         foreach ($hiddens as $k => $v) {
             $hiddens[$k] = Sitengine_Form_Element::getHidden($k, $v);
         }
         $query = array(Sitengine_Env::PARAM_SORT => $sorting->getActiveRule(), Sitengine_Env::PARAM_ORDER => $sorting->getActiveOrder(), Sitengine_Env::PARAM_PAGE => $pager->getPrevPage());
         $route = $this->_controller->getFrontController()->getRouter()->getRoute(Sitengine_Proto_Backend_Front::ROUTE_GOODIES);
         $uriPrevPage = $this->_controller->getRequest()->getBasePath() . '/' . $route->assemble();
         $uriPrevPage .= Sitengine_Controller_Request_Http::makeNameValueQuery($query);
         $query = array(Sitengine_Env::PARAM_SORT => $sorting->getActiveRule(), Sitengine_Env::PARAM_ORDER => $sorting->getActiveOrder(), Sitengine_Env::PARAM_PAGE => $pager->getNextPage());
         $route = $this->_controller->getFrontController()->getRouter()->getRoute(Sitengine_Proto_Backend_Front::ROUTE_GOODIES);
         $uriNextPage = $this->_controller->getRequest()->getBasePath() . '/' . $route->assemble();
         $uriNextPage .= Sitengine_Controller_Request_Http::makeNameValueQuery($query);
         $pagerData = array('hiddens' => implode('', $hiddens), 'currPage' => $pager->getCurrPage(), 'nextPage' => $pager->getNextPage(), 'prevPage' => $pager->getPrevPage(), 'numPages' => $pager->getNumPages(), 'numItems' => $pager->getNumItems(), 'firstItem' => $pager->getFirstItem(), 'lastItem' => $pager->getLastItem(), 'uriPrevPage' => $uriPrevPage, 'uriNextPage' => $uriNextPage);
         ########################################################################
         #### URIS
         ########################################################################
         $args = array();
         $route = $this->_controller->getFrontController()->getRouter()->getRoute(Sitengine_Proto_Backend_Front::ROUTE_GOODIES_BATCH);
         $uriDoBatchDelete = $this->_controller->getRequest()->getBasePath() . '/' . $route->assemble($args, true);
         $args = array();
         $route = $this->_controller->getFrontController()->getRouter()->getRoute(Sitengine_Proto_Backend_Front::ROUTE_GOODIES_BATCH);
         $uriDoBatchUpdate = $this->_controller->getRequest()->getBasePath() . '/' . $route->assemble($args, true);
         $uris = array('submitDoBatchDelete' => $uriDoBatchDelete, 'submitDoBatchUpdate' => $uriDoBatchUpdate);
         ########################################################################
         #### METHODS
         ########################################################################
         $methods = array('doBatchDelete' => Sitengine_Env::METHOD_DELETE, 'doBatchUpdate' => Sitengine_Env::METHOD_PUT);
         ########################################################################
         #### COLLECT ALL DATA
         ########################################################################
         $hiddens = array(Sitengine_Env::PARAM_METHOD => '', Sitengine_Env::PARAM_PAGE => $valuePage, Sitengine_Env::PARAM_SORT => $sorting->getActiveRule(), Sitengine_Env::PARAM_ORDER => $sorting->getActiveOrder());
         foreach ($hiddens as $k => $v) {
             $hiddens[$k] = Sitengine_Form_Element::getHidden($k, $v);
         }
         return array('hiddens' => implode('', $hiddens), 'title' => $this->_controller->getTranslate()->translate('indexViewTitle'), 'URIS' => $uris, 'METHODS' => $methods, 'FILTER' => $filterData, 'SETTINGS' => $settingsData, 'SORTING' => $sortingData, 'DATA' => $list, 'PAGER' => $pagerData);
     } catch (Exception $exception) {
         require_once 'Sitengine/Proto/Backend/Goodies/Exception.php';
         throw new Sitengine_Proto_Backend_Goodies_Exception('list page error', $exception);
     }
 }
Пример #3
0
 protected function _getMainSection()
 {
     try {
         $valuePage = $this->_controller->getRequest()->get(Sitengine_Env::PARAM_PAGE);
         $table = $this->_controller->getFrontController()->getNewsletterPackage()->getCampaignsTable();
         $filter = $table->getFilterInstance($this->_controller->getRequest(), array('type' => Sitengine_Newsletter_Frontend_Campaigns_Controller::PARAM_FILTER_BY_TYPE, 'find' => Sitengine_Newsletter_Frontend_Campaigns_Controller::PARAM_FILTER_BY_FIND, 'reset' => Sitengine_Newsletter_Frontend_Campaigns_Controller::PARAM_FILTER_RESET), $this->_controller->getNamespace());
         $sorting = $table->getSortingInstance($this->_controller->getRequest()->get(Sitengine_Env::PARAM_SORT), $this->_controller->getRequest()->get(Sitengine_Env::PARAM_ORDER));
         ########################################################################
         #### SETTINGS
         ########################################################################
         $settingsIsActive = false;
         $settingsElements = array();
         ### ipp element ###
         $defaultIpp = 20;
         $valueIpp = $this->_controller->getPreferences()->getItemsPerPage();
         $valueIpp = is_numeric($valueIpp) ? $valueIpp : $defaultIpp;
         $valueIpp = $valueIpp <= 100 && $valueIpp >= 1 ? $valueIpp : $defaultIpp;
         # set html input element
         $ippValues = array('' => $this->_controller->getTranslate()->translate('indexViewSettingsSectionItemsPerPage'), 5 => 5, 10 => 10, 20 => 20, 50 => 50, 100 => 100);
         $e = new Sitengine_Form_Element(Sitengine_Env::PARAM_IPP, $valueIpp);
         $e->setId('settings' . Sitengine_Env::PARAM_IPP);
         $e->setClass('settingsSelect');
         $settingsElements[Sitengine_Env::PARAM_IPP] = $e->getSelect($ippValues);
         $hiddens = array(Sitengine_Env::PARAM_SORT => $sorting->getActiveRule(), Sitengine_Env::PARAM_ORDER => $sorting->getActiveOrder());
         foreach ($hiddens as $k => $v) {
             $hiddens[$k] = Sitengine_Form_Element::getHidden($k, $v);
         }
         $settingsData = array('isActive' => $settingsIsActive, 'hiddens' => implode('', $hiddens), 'ELEMENTS' => $settingsElements);
         ########################################################################
         #### FILTER
         ########################################################################
         $e = new Sitengine_Form_Element(Sitengine_Newsletter_Frontend_Campaigns_Controller::PARAM_FILTER_BY_FIND, $filter->getVal(Sitengine_Newsletter_Frontend_Campaigns_Controller::PARAM_FILTER_BY_FIND));
         $e->setId('filter' . Sitengine_Newsletter_Frontend_Campaigns_Controller::PARAM_FILTER_BY_FIND);
         $e->setClass('filterText');
         $filter->setElement(Sitengine_Newsletter_Frontend_Campaigns_Controller::PARAM_FILTER_BY_FIND, $e->getText(20));
         $hiddens = array(Sitengine_Env::PARAM_SORT => $sorting->getActiveRule(), Sitengine_Env::PARAM_ORDER => $sorting->getActiveOrder());
         foreach ($hiddens as $k => $v) {
             $hiddens[$k] = Sitengine_Form_Element::getHidden($k, $v);
         }
         $query = array(Sitengine_Env::PARAM_SORT => $sorting->getActiveRule(), Sitengine_Env::PARAM_ORDER => $sorting->getActiveOrder(), Sitengine_Newsletter_Frontend_Campaigns_Controller::PARAM_FILTER_RESET => 1);
         $route = $this->_controller->getFrontController()->getRouter()->getRoute(Sitengine_Newsletter_Frontend_Front::ROUTE_CAMPAIGNS);
         $uriReset = $this->_controller->getRequest()->getBasePath() . '/' . $route->assemble();
         $uriReset .= Sitengine_Controller_Request_Http::makeNameValueQuery($query);
         $filterData = array('isActive' => $filter->isActive(), 'uriReset' => $uriReset, 'hiddens' => implode('', $hiddens), 'ELEMENTS' => $filter->getElements());
         ########################################################################
         #### SORTING
         ########################################################################
         $queries = array();
         foreach ($sorting->getOrdering() as $field => $order) {
             $query = array(Sitengine_Env::PARAM_SORT => $field, Sitengine_Env::PARAM_ORDER => $order);
             $route = $this->_controller->getFrontController()->getRouter()->getRoute(Sitengine_Newsletter_Frontend_Front::ROUTE_CAMPAIGNS);
             $queries[$field] = $this->_controller->getRequest()->getBasePath() . '/' . $route->assemble();
             $queries[$field] .= Sitengine_Controller_Request_Http::makeNameValueQuery($query);
         }
         $sortingData = array('QUERIES' => $queries, 'COLUMNS' => $sorting->getColumns());
         ########################################################################
         #### PAGER
         ########################################################################
         $pager = new Sitengine_Grid_Pager($valuePage, $valueIpp);
         ########################################################################
         #### LISTQUERY
         ########################################################################
         $name = $this->_controller->getFrontController()->getNewsletterPackage()->getCampaignsTableName();
         $whereClauses = array($this->_controller->getPermiso()->getDac()->getReadAccessSql($this->_controller->getFrontController()->getNewsletterPackage()->getAuthorizedGroups(), $name, false), $filter->getSql(''));
         $select = $table->select()->order($sorting->getClause())->limit($valueIpp, $pager->getOffset());
         foreach ($whereClauses as $clause) {
             if ($clause) {
                 $select->where($clause);
             }
         }
         $items = $table->fetchAll($select);
         # if current page is out of bounds - go to beginning of list
         if (!$items->count() && $pager->getCurrPage() > 1) {
             $pager = new Sitengine_Grid_Pager(1, $valueIpp);
             $select = $table->select()->order($sorting->getClause())->limit($valueIpp, 0);
             foreach ($whereClauses as $clause) {
                 if ($clause) {
                     $select->where($clause);
                 }
             }
             $items = $table->fetchAll($select);
         }
         # count total number of records
         $select = $table->select()->from($table, array('COUNT(*) AS count'));
         foreach ($whereClauses as $clause) {
             if ($clause) {
                 $select->where($clause);
             }
         }
         $count = $table->fetchRow($select);
         $pager->calculate($count->count);
         ########################################################################
         #### LISTDATA
         ########################################################################
         $list = array();
         foreach ($items as $item) {
             $row = $table->complementRow($item);
             #Sitengine_Debug::print_r($row);
             # uris
             $args = array(Sitengine_Env::PARAM_ID => $row['id']);
             $route = $this->_controller->getFrontController()->getRouter()->getRoute(Sitengine_Newsletter_Frontend_Front::ROUTE_CAMPAIGNS_SHARP);
             $row['uriUpdate'] = $this->_controller->getRequest()->getBasePath() . '/' . $route->assemble($args, true);
             $list[] = $row;
         }
         ########################################################################
         #### PAGER DATA
         ########################################################################
         $hiddens = array(Sitengine_Env::PARAM_SORT => $sorting->getActiveRule(), Sitengine_Env::PARAM_ORDER => $sorting->getActiveOrder());
         foreach ($hiddens as $k => $v) {
             $hiddens[$k] = Sitengine_Form_Element::getHidden($k, $v);
         }
         $query = array(Sitengine_Env::PARAM_SORT => $sorting->getActiveRule(), Sitengine_Env::PARAM_ORDER => $sorting->getActiveOrder(), Sitengine_Env::PARAM_PAGE => $pager->getPrevPage());
         $route = $this->_controller->getFrontController()->getRouter()->getRoute(Sitengine_Newsletter_Frontend_Front::ROUTE_CAMPAIGNS);
         $uriPrevPage = $this->_controller->getRequest()->getBasePath() . '/' . $route->assemble();
         $uriPrevPage .= Sitengine_Controller_Request_Http::makeNameValueQuery($query);
         $query = array(Sitengine_Env::PARAM_SORT => $sorting->getActiveRule(), Sitengine_Env::PARAM_ORDER => $sorting->getActiveOrder(), Sitengine_Env::PARAM_PAGE => $pager->getNextPage());
         $route = $this->_controller->getFrontController()->getRouter()->getRoute(Sitengine_Newsletter_Frontend_Front::ROUTE_CAMPAIGNS);
         $uriNextPage = $this->_controller->getRequest()->getBasePath() . '/' . $route->assemble();
         $uriNextPage .= Sitengine_Controller_Request_Http::makeNameValueQuery($query);
         $currPageInput = new Sitengine_Form_Element(Sitengine_Env::PARAM_PAGE, $pager->getCurrPage());
         $currPageInput->setClass('pagerInput');
         $pagerData = array('hiddens' => implode('', $hiddens), 'currPageInput' => $currPageInput->getText(2), 'currPage' => $pager->getCurrPage(), 'nextPage' => $pager->getNextPage(), 'prevPage' => $pager->getPrevPage(), 'numPages' => $pager->getNumPages(), 'numItems' => $pager->getNumItems(), 'firstItem' => $pager->getFirstItem(), 'lastItem' => $pager->getLastItem(), 'uriPrevPage' => $uriPrevPage, 'uriNextPage' => $uriNextPage);
         ########################################################################
         #### COLLECT ALL DATA
         ########################################################################
         return array('FILTER' => $filterData, 'SETTINGS' => $settingsData, 'SORTING' => $sortingData, 'DATA' => $list, 'PAGER' => $pagerData);
     } catch (Exception $exception) {
         require_once 'Sitengine/Newsletter/Frontend/Campaigns/Exception.php';
         throw new Sitengine_Newsletter_Frontend_Campaigns_Exception('list page error', $exception);
     }
 }
Пример #4
0
 protected function _getMainSection()
 {
     try {
         $valuePage = $this->_controller->getRequest()->get(Sitengine_Env::PARAM_PAGE);
         $filter = $this->_controller->getViewHelper()->getSearchFilterInstance();
         $sorting = $this->_controller->getViewHelper()->getSortingInstance();
         ########################################################################
         #### SETTINGS
         ########################################################################
         $settingsIsActive = false;
         $settingsElements = array();
         ### transcript element ###
         $transcripts = $this->_controller->getTranscripts();
         $transcripts->setLanguage($this->_controller->getPreferences()->getTranscript());
         if (!$transcripts->isDefault()) {
             $settingsIsActive = true;
         }
         # set html input element
         $languages = array();
         foreach ($this->_controller->getTranscripts()->get() as $symbol) {
             $languages[$symbol] = $this->_controller->getTranslate()->translate('languages' . ucfirst($symbol));
         }
         $e = new Sitengine_Form_Element(Sitengine_Env::PARAM_TRANSCRIPT, $this->_controller->getTranscripts()->getSymbol());
         $e->setId('settings' . Sitengine_Env::PARAM_TRANSCRIPT);
         $e->setClass('settingsSelect');
         $settingsElements[Sitengine_Env::PARAM_TRANSCRIPT] = $e->getSelect($languages);
         ### ipp element ###
         $defaultIpp = 20;
         $valueIpp = $this->_controller->getPreferences()->getItemsPerPage();
         $valueIpp = is_numeric($valueIpp) ? $valueIpp : $defaultIpp;
         $valueIpp = $valueIpp <= 100 && $valueIpp >= 1 ? $valueIpp : $defaultIpp;
         # set html input element
         $ippValues = array('' => $this->_controller->getTranslate()->translate('labelsSettingsSectionItemsPerPage'), 5 => 5, 10 => 10, 20 => 20, 50 => 50, 100 => 100);
         $e = new Sitengine_Form_Element(Sitengine_Env::PARAM_IPP, $valueIpp);
         $e->setId('settings' . Sitengine_Env::PARAM_IPP);
         $e->setClass('settingsSelect');
         $settingsElements[Sitengine_Env::PARAM_IPP] = $e->getSelect($ippValues);
         $hiddens = array(Sitengine_Env::PARAM_SORT => $sorting->getActiveRule(), Sitengine_Env::PARAM_ORDER => $sorting->getActiveOrder());
         foreach ($hiddens as $k => $v) {
             $hiddens[$k] = Sitengine_Form_Element::getHidden($k, $v);
         }
         $settingsData = array('isActive' => $settingsIsActive, 'hiddens' => implode('', $hiddens), 'ELEMENTS' => $settingsElements);
         ########################################################################
         #### FILTER
         ########################################################################
         $e = new Sitengine_Form_Element(Sitengine_Sitemap_Backend_Controller::PARAM_SEARCH_BY_TYPE, $filter->getVal(Sitengine_Sitemap_Backend_Controller::PARAM_SEARCH_BY_TYPE));
         $e->setId('filter' . Sitengine_Sitemap_Backend_Controller::PARAM_SEARCH_BY_TYPE);
         $e->setClass('filterSelect');
         $filter->setElement(Sitengine_Sitemap_Backend_Controller::PARAM_SEARCH_BY_TYPE, $e->getSelect($this->_controller->getTranslate()->translateGroup('fieldValsSearchByType')->toArray()));
         $e = new Sitengine_Form_Element(Sitengine_Sitemap_Backend_Controller::PARAM_SEARCH_BY_FIND, $filter->getVal(Sitengine_Sitemap_Backend_Controller::PARAM_SEARCH_BY_FIND));
         $e->setId('filter' . Sitengine_Sitemap_Backend_Controller::PARAM_SEARCH_BY_FIND);
         $e->setClass('filterText');
         $filter->setElement(Sitengine_Sitemap_Backend_Controller::PARAM_SEARCH_BY_FIND, $e->getText(20));
         $hiddens = array(Sitengine_Env::PARAM_SORT => $sorting->getActiveRule(), Sitengine_Env::PARAM_ORDER => $sorting->getActiveOrder());
         foreach ($hiddens as $k => $v) {
             $hiddens[$k] = Sitengine_Form_Element::getHidden($k, $v);
         }
         $args = array(Sitengine_Env::PARAM_ACTION => $this->_controller->getRequest()->getActionName(), Sitengine_Env::PARAM_SORT => $sorting->getActiveRule(), Sitengine_Env::PARAM_ORDER => $sorting->getActiveOrder(), Sitengine_Sitemap_Backend_Controller::PARAM_SEARCH_RESET => 1);
         $route = $this->_controller->getFrontController()->getRouter()->getRoute(Sitengine_Sitemap_Backend_Front::ROUTE_INDEX);
         $uriReset = $this->_controller->getRequest()->getBasePath() . '/' . $route->assemble($args, true);
         $filterData = array('isActive' => $filter->isActive(), 'uriReset' => $uriReset, 'hiddens' => implode('', $hiddens), 'ELEMENTS' => $filter->getElements());
         $sortingData = array();
         $pagerData = array();
         $list = array();
         if ($filter->isActive()) {
             ########################################################################
             #### SORTING
             ########################################################################
             $queries = array();
             foreach ($sorting->getOrdering() as $field => $order) {
                 $args = array(Sitengine_Env::PARAM_ACTION => $this->_controller->getRequest()->getActionName(), Sitengine_Sitemap_Backend_Controller::PARAM_SEARCH_BY_FIND => $filter->getVal(Sitengine_Sitemap_Backend_Controller::PARAM_SEARCH_BY_FIND), Sitengine_Env::PARAM_SORT => $field, Sitengine_Env::PARAM_ORDER => $order);
                 $route = $this->_controller->getFrontController()->getRouter()->getRoute(Sitengine_Sitemap_Backend_Front::ROUTE_INDEX);
                 $queries[$field] = $this->_controller->getRequest()->getBasePath() . '/' . $route->assemble($args, true);
             }
             $sortingData = array('QUERIES' => $queries, 'COLUMNS' => $sorting->getColumns());
             ########################################################################
             #### PAGER
             ########################################################################
             $pager = new Sitengine_Grid_Pager($valuePage, $valueIpp);
             ########################################################################
             #### LISTQUERY
             ########################################################################
             $q = 'SELECT';
             $q .= ' id,';
             $q .= ' cdate,';
             $q .= ' mdate,';
             $q .= ' keyword,';
             $q .= ' type,';
             $q .= ' IF(htmlLang' . $this->_controller->getTranscripts()->getIndex() . '="", htmlLang' . $this->_controller->getTranscripts()->getDefaultIndex() . ', htmlLang' . $this->_controller->getTranscripts()->getIndex() . ') AS html,';
             $q .= ' IF(htmlLang' . $this->_controller->getTranscripts()->getIndex() . '="", 1, 0) AS transcriptMissing';
             $q .= ' FROM';
             $q .= ' ' . $this->_controller->getFrontController()->getSitemapPackage()->getTableSitemap();
             $q .= ' WHERE 1 = 1';
             #$q .= ' '.Sitengine_Permiso::FIELD_OID.' = "'.$this->_controller->getPermiso()->getOrganization()->getId().'"';
             $q .= $filter->getSql();
             $q .= $this->_controller->getPermiso()->getDac()->getReadAccessSql($this->_controller->getAuthorizedGroups());
             $q .= $sorting->getClause(true);
             $sql = $this->_controller->getDatabase()->limit($q, $valueIpp, $pager->getOffset());
             $statement = $this->_controller->getDatabase()->prepare($sql);
             $statement->execute();
             $list = $statement->fetchAll();
             if ($pager->getCurrPage() > 1 && !sizeof($list)) {
                 # current page is out of bounds - go to beginning of list
                 $pager = new Sitengine_Grid_Pager(1, $valueIpp);
                 $sql = $this->_controller->getDatabase()->limit($q, $valueIpp, 0);
                 $statement = $this->_controller->getDatabase()->prepare($sql);
                 $statement->execute();
                 $list = $statement->fetchAll();
             }
             #print $sql;
             #Sitengine_Debug::print_r($list);
             # count full result
             $q = preg_replace('/SELECT .* FROM/', 'SELECT COUNT(*) AS count FROM', $q);
             $q = preg_replace('/ORDER BY .*/', '', $q);
             $statement = $this->_controller->getDatabase()->prepare($q);
             $statement->execute();
             $result = $statement->fetchAll();
             $pager->calculate($result[0]['count']);
             ########################################################################
             #### LISTDATA
             ########################################################################
             foreach ($list as $count => $row) {
                 # uris
                 switch ($row['type']) {
                     case Sitengine_Sitemap::ITEMTYPE_FILE:
                         $updateAction = Sitengine_Sitemap_Backend_Controller::ACTION_UPDATEFILE;
                         break;
                     case Sitengine_Sitemap::ITEMTYPE_PAGE:
                         $updateAction = Sitengine_Sitemap_Backend_Controller::ACTION_UPDATEPAGE;
                         break;
                     case Sitengine_Sitemap::ITEMTYPE_MASK:
                         $updateAction = Sitengine_Sitemap_Backend_Controller::ACTION_UPDATEMASK;
                         break;
                     case Sitengine_Sitemap::ITEMTYPE_LAYER:
                         $updateAction = Sitengine_Sitemap_Backend_Controller::ACTION_UPDATELAYER;
                         break;
                     case Sitengine_Sitemap::ITEMTYPE_SNIPPET:
                         $updateAction = Sitengine_Sitemap_Backend_Controller::ACTION_UPDATESNIPPET;
                         break;
                 }
                 $args = array(Sitengine_Env::PARAM_ACTION => $updateAction, Sitengine_Env::PARAM_ID => $row['id']);
                 $route = $this->_controller->getFrontController()->getRouter()->getRoute(Sitengine_Sitemap_Backend_Front::ROUTE_INDEX);
                 $uriUpdate = $this->_controller->getRequest()->getBasePath() . '/' . $route->assemble($args, true);
                 #$row['childCount'] = $this->_controller->getViewHelper()->countChildren($row['id']);
                 $row['uriUpdate'] = $uriUpdate;
                 $name = 'cdate';
                 $date = new Zend_Date($row[$name], Zend_Date::ISO_8601, $this->_controller->getLocale());
                 $date->setTimezone($this->_controller->getPreferences()->getTimezone());
                 $row[$name] = $date->get(Zend_Date::DATE_LONG, $this->_controller->getLocale()) . ' ';
                 $row[$name] .= $date->get(Zend_Date::TIME_LONG, $this->_controller->getLocale());
                 $list[$count] = $row;
             }
             ########################################################################
             #### PAGER DATA
             ########################################################################
             $hiddens = array(Sitengine_Sitemap_Backend_Controller::PARAM_SEARCH_BY_FIND => $filter->getVal(Sitengine_Sitemap_Backend_Controller::PARAM_SEARCH_BY_FIND), Sitengine_Sitemap_Backend_Controller::PARAM_SEARCH_BY_TYPE => $filter->getVal(Sitengine_Sitemap_Backend_Controller::PARAM_SEARCH_BY_TYPE), Sitengine_Env::PARAM_SORT => $sorting->getActiveRule(), Sitengine_Env::PARAM_ORDER => $sorting->getActiveOrder());
             foreach ($hiddens as $k => $v) {
                 $hiddens[$k] = Sitengine_Form_Element::getHidden($k, $v);
             }
             $args = array(Sitengine_Env::PARAM_ACTION => $this->_controller->getRequest()->getActionName(), Sitengine_Sitemap_Backend_Controller::PARAM_SEARCH_BY_FIND => $filter->getVal(Sitengine_Sitemap_Backend_Controller::PARAM_SEARCH_BY_FIND), Sitengine_Sitemap_Backend_Controller::PARAM_SEARCH_BY_TYPE => $filter->getVal(Sitengine_Sitemap_Backend_Controller::PARAM_SEARCH_BY_TYPE), Sitengine_Env::PARAM_SORT => $sorting->getActiveRule(), Sitengine_Env::PARAM_ORDER => $sorting->getActiveOrder(), Sitengine_Env::PARAM_PAGE => $pager->getPrevPage());
             $route = $this->_controller->getFrontController()->getRouter()->getRoute(Sitengine_Sitemap_Backend_Front::ROUTE_INDEX);
             $uriPrevPage = $this->_controller->getRequest()->getBasePath() . '/' . $route->assemble($args, true);
             $args = array(Sitengine_Env::PARAM_ACTION => $this->_controller->getRequest()->getActionName(), Sitengine_Sitemap_Backend_Controller::PARAM_SEARCH_BY_FIND => $filter->getVal(Sitengine_Sitemap_Backend_Controller::PARAM_SEARCH_BY_FIND), Sitengine_Sitemap_Backend_Controller::PARAM_SEARCH_BY_TYPE => $filter->getVal(Sitengine_Sitemap_Backend_Controller::PARAM_SEARCH_BY_TYPE), Sitengine_Env::PARAM_SORT => $sorting->getActiveRule(), Sitengine_Env::PARAM_ORDER => $sorting->getActiveOrder(), Sitengine_Env::PARAM_PAGE => $pager->getNextPage());
             $route = $this->_controller->getFrontController()->getRouter()->getRoute(Sitengine_Sitemap_Backend_Front::ROUTE_INDEX);
             $uriNextPage = $this->_controller->getRequest()->getBasePath() . '/' . $route->assemble($args, true);
             $currPageInput = new Sitengine_Form_Element(Sitengine_Env::PARAM_PAGE, $pager->getCurrPage());
             $currPageInput->setClass('pagerInput');
             $pagerData = array('hiddens' => implode('', $hiddens), 'currPageInput' => $currPageInput->getText(2), 'currPage' => $pager->getCurrPage(), 'nextPage' => $pager->getNextPage(), 'prevPage' => $pager->getPrevPage(), 'numPages' => $pager->getNumPages(), 'numItems' => $pager->getNumItems(), 'firstItem' => $pager->getFirstItem(), 'lastItem' => $pager->getLastItem(), 'uriPrevPage' => $uriPrevPage, 'uriNextPage' => $uriNextPage);
         }
         ########################################################################
         #### COLLECT ALL DATA
         ########################################################################
         return array('title' => $this->_controller->getTranslate()->translate('labelsSearchFormTitle'), 'FILTER' => $filterData, 'SETTINGS' => $settingsData, 'SORTING' => $sortingData, 'DATA' => $list, 'PAGER' => $pagerData);
     } catch (Exception $exception) {
         require_once 'Sitengine/Sitemap/Backend/Exception.php';
         throw new Sitengine_Sitemap_Backend_Exception('list page error', $exception);
     }
 }
Пример #5
0
 protected function _getMainSection()
 {
     try {
         $valuePage = $this->_controller->getRequest()->get(Sitengine_Env::PARAM_PAGE);
         $table = $this->_controller->getFrontController()->getNewsletterPackage()->getAttachmentsTable();
         $filter = $table->getFilterInstance($this->_controller->getRequest(), array('find' => Sitengine_Newsletter_Backend_Campaigns_Attachments_Controller::PARAM_FILTER_BY_FIND, 'reset' => Sitengine_Newsletter_Backend_Campaigns_Attachments_Controller::PARAM_FILTER_RESET), $this->_controller->getNamespace());
         $sorting = $table->getSortingInstance($this->_controller->getRequest()->get(Sitengine_Env::PARAM_SORT), $this->_controller->getRequest()->get(Sitengine_Env::PARAM_ORDER));
         ########################################################################
         #### SETTINGS
         ########################################################################
         $settingsIsActive = false;
         $settingsElements = array();
         ### ipp element ###
         $defaultIpp = 20;
         $valueIpp = $this->_controller->getPreferences()->getItemsPerPage();
         $valueIpp = is_numeric($valueIpp) ? $valueIpp : $defaultIpp;
         $valueIpp = $valueIpp <= 100 && $valueIpp >= 1 ? $valueIpp : $defaultIpp;
         # set html input element
         $ippValues = array('' => $this->_controller->getTranslate()->translate('indexViewSettingsSectionItemsPerPage'), 5 => 5, 10 => 10, 20 => 20, 50 => 50, 100 => 100);
         $e = new Sitengine_Form_Element(Sitengine_Env::PARAM_IPP, $valueIpp);
         $e->setId('settings' . Sitengine_Env::PARAM_IPP);
         $e->setClass('settingsSelect');
         $settingsElements[Sitengine_Env::PARAM_IPP] = $e->getSelect($ippValues);
         $hiddens = array(Sitengine_Env::PARAM_SORT => $sorting->getActiveRule(), Sitengine_Env::PARAM_ORDER => $sorting->getActiveOrder());
         foreach ($hiddens as $k => $v) {
             $hiddens[$k] = Sitengine_Form_Element::getHidden($k, $v);
         }
         $settingsData = array('isActive' => $settingsIsActive, 'hiddens' => implode('', $hiddens), 'ELEMENTS' => $settingsElements);
         ########################################################################
         #### FILTER
         ########################################################################
         $e = new Sitengine_Form_Element(Sitengine_Newsletter_Backend_Campaigns_Attachments_Controller::PARAM_FILTER_BY_FIND, $filter->getVal(Sitengine_Newsletter_Backend_Campaigns_Attachments_Controller::PARAM_FILTER_BY_FIND));
         $e->setId('filter' . Sitengine_Newsletter_Backend_Campaigns_Attachments_Controller::PARAM_FILTER_BY_FIND);
         $e->setClass('filterText');
         $filter->setElement(Sitengine_Newsletter_Backend_Campaigns_Attachments_Controller::PARAM_FILTER_BY_FIND, $e->getText(20));
         $hiddens = array(Sitengine_Env::PARAM_SORT => $sorting->getActiveRule(), Sitengine_Env::PARAM_ORDER => $sorting->getActiveOrder());
         foreach ($hiddens as $k => $v) {
             $hiddens[$k] = Sitengine_Form_Element::getHidden($k, $v);
         }
         $args = array(Sitengine_Env::PARAM_ANCESTORID => $this->_controller->getEntity()->getAncestorId());
         $query = array(Sitengine_Env::PARAM_SORT => $sorting->getActiveRule(), Sitengine_Env::PARAM_ORDER => $sorting->getActiveOrder(), Sitengine_Newsletter_Backend_Campaigns_Attachments_Controller::PARAM_FILTER_RESET => 1);
         $route = $this->_controller->getFrontController()->getRouter()->getRoute(Sitengine_Newsletter_Backend_Front::ROUTE_CAMPAIGNS_ATTACHMENTS);
         $uriReset = $this->_controller->getRequest()->getBasePath() . '/' . $route->assemble($args, true);
         $uriReset .= Sitengine_Controller_Request_Http::makeNameValueQuery($query);
         $filterData = array('isActive' => $filter->isActive(), 'uriReset' => $uriReset, 'hiddens' => implode('', $hiddens), 'ELEMENTS' => $filter->getElements());
         ########################################################################
         #### SORTING
         ########################################################################
         $queries = array();
         foreach ($sorting->getOrdering() as $field => $order) {
             $args = array(Sitengine_Env::PARAM_ANCESTORID => $this->_controller->getEntity()->getAncestorId());
             $query = array(Sitengine_Env::PARAM_SORT => $field, Sitengine_Env::PARAM_ORDER => $order);
             $route = $this->_controller->getFrontController()->getRouter()->getRoute(Sitengine_Newsletter_Backend_Front::ROUTE_CAMPAIGNS_ATTACHMENTS);
             $queries[$field] = $this->_controller->getRequest()->getBasePath() . '/' . $route->assemble($args, true);
             $queries[$field] .= Sitengine_Controller_Request_Http::makeNameValueQuery($query);
         }
         $sortingData = array('QUERIES' => $queries, 'COLUMNS' => $sorting->getColumns());
         ########################################################################
         #### PAGER
         ########################################################################
         $pager = new Sitengine_Grid_Pager($valuePage, $valueIpp);
         ########################################################################
         #### LISTQUERY
         ########################################################################
         $name = $this->_controller->getFrontController()->getNewsletterPackage()->getAttachmentsTableName();
         $whereClauses = array($this->_controller->getDatabase()->quoteInto('campaignId = ?', $this->_controller->getEntity()->getAncestorId()), $this->_controller->getPermiso()->getDac()->getReadAccessSql($this->_controller->getFrontController()->getNewsletterPackage()->getAuthorizedGroups(), $name, false), $filter->getSql(''));
         $select = $table->select()->order($sorting->getClause())->limit($valueIpp, $pager->getOffset());
         foreach ($whereClauses as $clause) {
             if ($clause) {
                 $select->where($clause);
             }
         }
         $items = $table->fetchAll($select);
         # if current page is out of bounds - go to beginning of list
         if (!$items->count() && $pager->getCurrPage() > 1) {
             $pager = new Sitengine_Grid_Pager(1, $valueIpp);
             $select = $table->select()->order($sorting->getClause())->limit($valueIpp, 0);
             foreach ($whereClauses as $clause) {
                 if ($clause) {
                     $select->where($clause);
                 }
             }
             $items = $table->fetchAll($select);
         }
         # count total number of records
         $select = $table->select()->from($table, array('COUNT(*) AS count'));
         foreach ($whereClauses as $clause) {
             if ($clause) {
                 $select->where($clause);
             }
         }
         $count = $table->fetchRow($select);
         $pager->calculate($count->count);
         ########################################################################
         #### LISTDATA
         ########################################################################
         $markedRows = $this->_controller->getMarkedRows();
         $list = array();
         foreach ($items as $item) {
             $row = $table->complementRow($item);
             # row selector checkbox
             $p = 'SELECTROWITEM' . $row['id'];
             $s = sizeof($markedRows) && isset($markedRows[$row['id']]) ? $this->_controller->getRequest()->getPost($p) : 0;
             $e = new Sitengine_Form_Element($p, 1);
             $e->setClass('listformCheckbox');
             $row['rowSelectCheckbox'] = $e->getCheckbox($s);
             $fileUrl = $row['file1OriginalUri'];
             $e = new Sitengine_Form_Element('fileUrl', preg_replace('/&amp;/', '&', $fileUrl));
             $e->setClass('listformText');
             $row['file1OriginalElement'] = $e->getText(80);
             # uris
             $args = array(Sitengine_Env::PARAM_ANCESTORID => $this->_controller->getEntity()->getAncestorId(), Sitengine_Env::PARAM_ID => $row['id']);
             $route = $this->_controller->getFrontController()->getRouter()->getRoute(Sitengine_Newsletter_Backend_Front::ROUTE_CAMPAIGNS_ATTACHMENTS_SHARP);
             $row['uriUpdate'] = $this->_controller->getRequest()->getBasePath() . '/' . $route->assemble($args, true);
             $row['isMarked'] = isset($markedRows[$row['id']]) ? $markedRows[$row['id']] : 0;
             $name = 'cdate';
             $date = new Zend_Date($row[$name], Zend_Date::ISO_8601, $this->_controller->getLocale());
             $date->setTimezone($this->_controller->getPreferences()->getTimezone());
             $row[$name] = $date->get(Zend_Date::DATE_LONG, $this->_controller->getLocale()) . ' ';
             $row[$name] .= $date->get(Zend_Date::TIME_LONG, $this->_controller->getLocale());
             $list[] = $row;
         }
         ########################################################################
         #### PAGER DATA
         ########################################################################
         $hiddens = array(Sitengine_Env::PARAM_SORT => $sorting->getActiveRule(), Sitengine_Env::PARAM_ORDER => $sorting->getActiveOrder());
         foreach ($hiddens as $k => $v) {
             $hiddens[$k] = Sitengine_Form_Element::getHidden($k, $v);
         }
         $args = array(Sitengine_Env::PARAM_ANCESTORID => $this->_controller->getEntity()->getAncestorId());
         $query = array(Sitengine_Env::PARAM_SORT => $sorting->getActiveRule(), Sitengine_Env::PARAM_ORDER => $sorting->getActiveOrder(), Sitengine_Env::PARAM_PAGE => $pager->getPrevPage());
         $route = $this->_controller->getFrontController()->getRouter()->getRoute(Sitengine_Newsletter_Backend_Front::ROUTE_CAMPAIGNS_ATTACHMENTS);
         $uriPrevPage = $this->_controller->getRequest()->getBasePath() . '/' . $route->assemble($args, true);
         $uriPrevPage .= Sitengine_Controller_Request_Http::makeNameValueQuery($query);
         $args = array(Sitengine_Env::PARAM_ANCESTORID => $this->_controller->getEntity()->getAncestorId());
         $query = array(Sitengine_Env::PARAM_SORT => $sorting->getActiveRule(), Sitengine_Env::PARAM_ORDER => $sorting->getActiveOrder(), Sitengine_Env::PARAM_PAGE => $pager->getNextPage());
         $route = $this->_controller->getFrontController()->getRouter()->getRoute(Sitengine_Newsletter_Backend_Front::ROUTE_CAMPAIGNS_ATTACHMENTS);
         $uriNextPage = $this->_controller->getRequest()->getBasePath() . '/' . $route->assemble($args, true);
         $uriNextPage .= Sitengine_Controller_Request_Http::makeNameValueQuery($query);
         $currPageInput = new Sitengine_Form_Element(Sitengine_Env::PARAM_PAGE, $pager->getCurrPage());
         $currPageInput->setClass('pagerInput');
         $pagerData = array('hiddens' => implode('', $hiddens), 'currPageInput' => $currPageInput->getText(2), 'currPage' => $pager->getCurrPage(), 'nextPage' => $pager->getNextPage(), 'prevPage' => $pager->getPrevPage(), 'numPages' => $pager->getNumPages(), 'numItems' => $pager->getNumItems(), 'firstItem' => $pager->getFirstItem(), 'lastItem' => $pager->getLastItem(), 'uriPrevPage' => $uriPrevPage, 'uriNextPage' => $uriNextPage);
         ########################################################################
         #### URIS
         ########################################################################
         $args = array(Sitengine_Env::PARAM_ANCESTORID => $this->_controller->getEntity()->getAncestorId());
         $route = $this->_controller->getFrontController()->getRouter()->getRoute(Sitengine_Newsletter_Backend_Front::ROUTE_CAMPAIGNS_ATTACHMENTS_BATCH);
         $uriDoBatchDelete = $this->_controller->getRequest()->getBasePath() . '/' . $route->assemble($args, true);
         $args = array(Sitengine_Env::PARAM_ANCESTORID => $this->_controller->getEntity()->getAncestorId());
         $route = $this->_controller->getFrontController()->getRouter()->getRoute(Sitengine_Newsletter_Backend_Front::ROUTE_CAMPAIGNS_ATTACHMENTS_BATCH);
         $uriDoBatchUpdate = $this->_controller->getRequest()->getBasePath() . '/' . $route->assemble($args, true);
         $uris = array('submitDoBatchDelete' => $uriDoBatchDelete, 'submitDoBatchUpdate' => $uriDoBatchUpdate);
         ########################################################################
         #### METHODS
         ########################################################################
         $methods = array('doBatchDelete' => Sitengine_Env::METHOD_DELETE, 'doBatchUpdate' => Sitengine_Env::METHOD_PUT);
         ########################################################################
         #### COLLECT ALL DATA
         ########################################################################
         $hiddens = array(Sitengine_Env::PARAM_METHOD => '', Sitengine_Env::PARAM_PAGE => $valuePage, Sitengine_Env::PARAM_SORT => $sorting->getActiveRule(), Sitengine_Env::PARAM_ORDER => $sorting->getActiveOrder());
         foreach ($hiddens as $k => $v) {
             $hiddens[$k] = Sitengine_Form_Element::getHidden($k, $v);
         }
         return array('hiddens' => implode('', $hiddens), 'title' => $this->_controller->getTranslate()->translate('indexViewTitle'), 'URIS' => $uris, 'METHODS' => $methods, 'FILTER' => $filterData, 'SETTINGS' => $settingsData, 'SORTING' => $sortingData, 'DATA' => $list, 'PAGER' => $pagerData);
     } catch (Exception $exception) {
         require_once 'Sitengine/Newsletter/Backend/Campaigns/Attachments/Exception.php';
         throw new Sitengine_Newsletter_Backend_Campaigns_Attachments_Exception('list page error', $exception);
     }
 }
Пример #6
0
 protected function _getMainSection()
 {
     try {
         $valuePage = $this->_controller->getRequest()->get(Sitengine_Env::PARAM_PAGE);
         $table = $this->_controller->getFrontController()->getBlogPackage()->getBlogsTable();
         $table->setTranscript($this->_controller->getPreferences()->getTranscript());
         $filter = $table->getFilterInstance($this->_controller->getRequest(), array('find' => Sitengine_Blog_Frontend_Blogs_Controller::PARAM_FILTER_BY_FIND, 'reset' => Sitengine_Blog_Frontend_Blogs_Controller::PARAM_FILTER_RESET), $this->_controller->getNamespace());
         $sorting = $table->getSortingInstance($this->_controller->getRequest()->get(Sitengine_Env::PARAM_SORT), $this->_controller->getRequest()->get(Sitengine_Env::PARAM_ORDER));
         ########################################################################
         #### SETTINGS
         ########################################################################
         $settingsIsActive = false;
         $settingsElements = array();
         /*
         ### transcript element ###
         $transcripts = $table->getTranscripts();
         $transcripts->setLanguage($this->_controller->getPreferences()->getLanguage());
         if(!$transcripts->isDefault()) { $settingsIsActive = true; }
         # set html input element
         $languages = array();
         foreach($transcripts->get() as $symbol) {
         	$languages[$symbol] = $this->_controller->getTranslate()->translate('languages'.ucfirst($symbol));
         }
         $e = new Sitengine_Form_Element(Sitengine_Env::PARAM_TRANSCRIPT, $transcripts->getSymbol());
         $e->setId('settings'.Sitengine_Env::PARAM_TRANSCRIPT);
         $e->setClass('settingsSelect');
         $settingsElements[Sitengine_Env::PARAM_TRANSCRIPT] = $e->getSelect($languages);
         */
         ### ipp element ###
         $defaultIpp = 20;
         $valueIpp = $this->_controller->getPreferences()->getItemsPerPage();
         $valueIpp = is_numeric($valueIpp) ? $valueIpp : $defaultIpp;
         $valueIpp = $valueIpp <= 100 && $valueIpp >= 1 ? $valueIpp : $defaultIpp;
         # set html input element
         $ippValues = array('' => $this->_controller->getTranslate()->translate('labelsSettingsSectionItemsPerPage'), 5 => 5, 10 => 10, 20 => 20, 50 => 50, 100 => 100);
         $e = new Sitengine_Form_Element(Sitengine_Env::PARAM_IPP, $valueIpp);
         $e->setId('settings' . Sitengine_Env::PARAM_IPP);
         $e->setClass('settingsSelect');
         $settingsElements[Sitengine_Env::PARAM_IPP] = $e->getSelect($ippValues);
         $hiddens = array(Sitengine_Env::PARAM_SORT => $sorting->getActiveRule(), Sitengine_Env::PARAM_ORDER => $sorting->getActiveOrder());
         foreach ($hiddens as $k => $v) {
             $hiddens[$k] = Sitengine_Form_Element::getHidden($k, $v);
         }
         $settingsData = array('isActive' => $settingsIsActive, 'hiddens' => implode('', $hiddens), 'ELEMENTS' => $settingsElements);
         ########################################################################
         #### FILTER
         ########################################################################
         $e = new Sitengine_Form_Element(Sitengine_Blog_Frontend_Blogs_Controller::PARAM_FILTER_BY_FIND, $filter->getVal(Sitengine_Blog_Frontend_Blogs_Controller::PARAM_FILTER_BY_FIND));
         $e->setId('filter' . Sitengine_Blog_Frontend_Blogs_Controller::PARAM_FILTER_BY_FIND);
         $e->setClass('filterText');
         $filter->setElement(Sitengine_Blog_Frontend_Blogs_Controller::PARAM_FILTER_BY_FIND, $e->getText(20));
         $hiddens = array(Sitengine_Env::PARAM_SORT => $sorting->getActiveRule(), Sitengine_Env::PARAM_ORDER => $sorting->getActiveOrder());
         foreach ($hiddens as $k => $v) {
             $hiddens[$k] = Sitengine_Form_Element::getHidden($k, $v);
         }
         $query = array(Sitengine_Env::PARAM_SORT => $sorting->getActiveRule(), Sitengine_Env::PARAM_ORDER => $sorting->getActiveOrder(), Sitengine_Blog_Frontend_Blogs_Controller::PARAM_FILTER_RESET => 1);
         $route = $this->_controller->getFrontController()->getRouter()->getRoute(Sitengine_Blog_Frontend_Front::ROUTE_BLOGS);
         $uriReset = $this->_controller->getRequest()->getBasePath() . '/' . $route->assemble();
         $uriReset .= Sitengine_Controller_Request_Http::makeNameValueQuery($query);
         $filterData = array('isActive' => $filter->isActive(), 'uriReset' => $uriReset, 'hiddens' => implode('', $hiddens), 'ELEMENTS' => $filter->getElements(), 'DATA' => $filter->getData());
         ########################################################################
         #### SORTING
         ########################################################################
         $queries = array();
         foreach ($sorting->getOrdering() as $field => $order) {
             $query = array(Sitengine_Env::PARAM_SORT => $field, Sitengine_Env::PARAM_ORDER => $order);
             $route = $this->_controller->getFrontController()->getRouter()->getRoute(Sitengine_Blog_Frontend_Front::ROUTE_BLOGS);
             $queries[$field] = $this->_controller->getRequest()->getBasePath() . '/' . $route->assemble();
             $queries[$field] .= Sitengine_Controller_Request_Http::makeNameValueQuery($query);
         }
         $sortingData = array('QUERIES' => $queries, 'COLUMNS' => $sorting->getColumns());
         ########################################################################
         #### PAGER
         ########################################################################
         $pager = new Sitengine_Grid_Pager($valuePage, $valueIpp);
         ########################################################################
         #### LISTQUERY
         ########################################################################
         $name = $this->_controller->getFrontController()->getBlogPackage()->getBlogsTableName();
         $whereClauses = array("{$table}.publish = '1'", $filter->getSql(''));
         $select = $table->select()->order($sorting->getClause())->limit($valueIpp, $pager->getOffset());
         foreach ($whereClauses as $clause) {
             if ($clause) {
                 $select->where($clause);
             }
         }
         $items = $table->fetchAll($select);
         # if current page is out of bounds - go to beginning of list
         if (!$items->count() && $pager->getCurrPage() > 1) {
             $pager = new Sitengine_Grid_Pager(1, $valueIpp);
             $select = $table->select()->order($sorting->getClause())->limit($valueIpp, 0);
             foreach ($whereClauses as $clause) {
                 if ($clause) {
                     $select->where($clause);
                 }
             }
             $items = $table->fetchAll($select);
         }
         # count total number of records
         $select = $table->select()->from($table, array('COUNT(*) AS count'));
         foreach ($whereClauses as $clause) {
             if ($clause) {
                 $select->where($clause);
             }
         }
         $count = $table->fetchRow($select);
         $pager->calculate($count->count);
         ########################################################################
         #### LISTDATA
         ########################################################################
         #$markedRows = $this->_controller->getMarkedRows();
         $list = array();
         foreach ($items as $item) {
             $row = $table->complementRow($item);
             /*
             # row selector checkbox
             				$p = 'SELECTROWITEM'.$row['id'];
             				$s = (sizeof($markedRows) && isset($markedRows[$row['id']])) ? $this->_controller->getRequest()->getPost($p) : 0;
             				$e = new Sitengine_Form_Element($p, 1);
             				$e->setClass('listformCheckbox');
             				$row['rowSelectCheckbox'] = $e->getCheckbox($s);
             
             $n = 'publish';
             $p = 'UPDATEROWITEM'.$n.'ITEMID'.$row['id'];
             $h = 'UPDATEROWITEMCURRENT'.$n.'ITEMID'.$row['id'];
             $s = (sizeof($markedRows) && isset($markedRows[$row['id']])) ? $this->_controller->getRequest()->getPost($p) : $row[$n];
             $e = new Sitengine_Form_Element($p, 1);
             $e->setClass('listformCheckbox');
             $publish  = $e->getCheckbox($s);
             $publish .= Sitengine_Form_Element::getHidden($h, $row[$n]);
             
             # uris
             $uriUpdate = $this->_makeUpdateUri($row);
             */
             $args = array(Sitengine_Env::PARAM_ANCESTORID => $row['slug']);
             $route = $this->_controller->getFrontController()->getRouter()->getRoute(Sitengine_Blog_Frontend_Front::ROUTE_BLOGS_POSTS);
             $uriPostIndex = $this->_controller->getRequest()->getBasePath() . '/' . $route->assemble($args, true);
             /*
             $args = array(
                 Sitengine_Env::PARAM_ANCESTORID => $row['id']
             );
             $route = $this->_controller->getFrontController()->getRouter()->getRoute(Sitengine_Blog_Frontend_Front::ROUTE_BLOGS_POSTS_NEW);
             $uriPostInsert = $this->_controller->getRequest()->getBasePath().'/'.$route->assemble($args, true);
             
             
             $row['isMarked'] = (isset($markedRows[$row['id']])) ? $markedRows[$row['id']] : 0;
             $row['publishCheckbox'] = $publish;
             */
             $row['postCount'] = $this->_controller->getViewHelper()->countPosts($row['id']);
             $row['uriPostIndex'] = $uriPostIndex;
             #$row['uriPostInsert'] = $uriPostInsert;
             #$row['uriUpdate'] = $uriUpdate;
             #$row['cdate'] = $this->_controller->getViewHelper()->formatDate($row['cdate']);
             #$row['mdate'] = $this->_controller->getViewHelper()->formatDate($row['mdate']);
             $list[] = $row;
         }
         ########################################################################
         #### PAGER DATA
         ########################################################################
         $hiddens = array(Sitengine_Env::PARAM_SORT => $sorting->getActiveRule(), Sitengine_Env::PARAM_ORDER => $sorting->getActiveOrder());
         foreach ($hiddens as $k => $v) {
             $hiddens[$k] = Sitengine_Form_Element::getHidden($k, $v);
         }
         $query = array(Sitengine_Env::PARAM_SORT => $sorting->getActiveRule(), Sitengine_Env::PARAM_ORDER => $sorting->getActiveOrder(), Sitengine_Env::PARAM_PAGE => $pager->getPrevPage());
         $route = $this->_controller->getFrontController()->getRouter()->getRoute(Sitengine_Blog_Frontend_Front::ROUTE_BLOGS);
         $uriPrevPage = $this->_controller->getRequest()->getBasePath() . '/' . $route->assemble();
         $uriPrevPage .= Sitengine_Controller_Request_Http::makeNameValueQuery($query);
         $query = array(Sitengine_Env::PARAM_SORT => $sorting->getActiveRule(), Sitengine_Env::PARAM_ORDER => $sorting->getActiveOrder(), Sitengine_Env::PARAM_PAGE => $pager->getNextPage());
         $route = $this->_controller->getFrontController()->getRouter()->getRoute(Sitengine_Blog_Frontend_Front::ROUTE_BLOGS);
         $uriNextPage = $this->_controller->getRequest()->getBasePath() . '/' . $route->assemble();
         $uriNextPage .= Sitengine_Controller_Request_Http::makeNameValueQuery($query);
         $currPageInput = new Sitengine_Form_Element(Sitengine_Env::PARAM_PAGE, $pager->getCurrPage());
         $currPageInput->setClass('pagerInput');
         $pagerData = array('hiddens' => implode('', $hiddens), 'currPageInput' => $currPageInput->getText(2), 'currPage' => $pager->getCurrPage(), 'nextPage' => $pager->getNextPage(), 'prevPage' => $pager->getPrevPage(), 'numPages' => $pager->getNumPages(), 'numItems' => $pager->getNumItems(), 'firstItem' => $pager->getFirstItem(), 'lastItem' => $pager->getLastItem(), 'uriPrevPage' => $uriPrevPage, 'uriNextPage' => $uriNextPage);
         /*
         ########################################################################
         #### URIS
         ########################################################################
         $args = array();
         $route = $this->_controller->getFrontController()->getRouter()->getRoute(Sitengine_Blog_Frontend_Front::ROUTE_BLOGS_BATCH);
         $uriDoBatchDelete = $this->_controller->getRequest()->getBasePath().'/'.$route->assemble($args, true);
         
         $args = array();
         $route = $this->_controller->getFrontController()->getRouter()->getRoute(Sitengine_Blog_Frontend_Front::ROUTE_BLOGS_BATCH);
         $uriDoBatchUpdate = $this->_controller->getRequest()->getBasePath().'/'.$route->assemble($args, true);
         
         $uris = array(
         	'submitDoBatchDelete' => $uriDoBatchDelete,
         	'submitDoBatchUpdate' => $uriDoBatchUpdate
         );
         
         
         
         ########################################################################
         #### METHODS
         ########################################################################
         $methods = array(
         	'doBatchDelete' => Sitengine_Env::METHOD_DELETE,
         	'doBatchUpdate' => Sitengine_Env::METHOD_PUT
         );
         
         
         ########################################################################
         #### COLLECT ALL DATA
         ########################################################################
         $hiddens = array(
             Sitengine_Env::PARAM_METHOD => '',
             Sitengine_Env::PARAM_PAGE => $valuePage,
             Sitengine_Env::PARAM_SORT => $sorting->getActiveRule(),
             Sitengine_Env::PARAM_ORDER => $sorting->getActiveOrder()
         );
         foreach($hiddens as $k => $v) {
             $hiddens[$k] = Sitengine_Form_Element::getHidden($k, $v);
         }
         */
         return array('FILTER' => $filterData, 'SETTINGS' => $settingsData, 'SORTING' => $sortingData, 'DATA' => $list, 'PAGER' => $pagerData);
     } catch (Exception $exception) {
         require_once 'Sitengine/Blog/Frontend/Blogs/Exception.php';
         throw new Sitengine_Blog_Frontend_Blogs_Exception('list page error', $exception);
     }
 }
Пример #7
0
 protected function _getMainSection()
 {
     try {
         $valuePage = $this->_controller->getRequest()->get(Sitengine_Env::PARAM_PAGE);
         $filter = $this->_controller->getViewHelper()->getListFilterInstance();
         $sorting = $this->_controller->getViewHelper()->getSortingInstance();
         ########################################################################
         #### SETTINGS
         ########################################################################
         $settingsIsActive = false;
         $settingsElements = array();
         ### transcript element ###
         $transcripts = $this->_controller->getTranscripts();
         $transcripts->setLanguage($this->_controller->getPreferences()->getTranscript());
         if (!$transcripts->isDefault()) {
             $settingsIsActive = true;
         }
         # set html input element
         $languages = array();
         foreach ($this->_controller->getTranscripts()->get() as $symbol) {
             $languages[$symbol] = $this->_controller->getTranslate()->translate('languages' . ucfirst($symbol));
         }
         $e = new Sitengine_Form_Element(Sitengine_Env::PARAM_TRANSCRIPT, $this->_controller->getTranscripts()->getSymbol());
         $e->setId('settings' . Sitengine_Env::PARAM_TRANSCRIPT);
         $e->setClass('settingsSelect');
         $settingsElements[Sitengine_Env::PARAM_TRANSCRIPT] = $e->getSelect($languages);
         ### ipp element ###
         $defaultIpp = 20;
         $valueIpp = $this->_controller->getPreferences()->getItemsPerPage();
         $valueIpp = is_numeric($valueIpp) ? $valueIpp : $defaultIpp;
         $valueIpp = $valueIpp <= 100 && $valueIpp >= 1 ? $valueIpp : $defaultIpp;
         # set html input element
         $ippValues = array('' => $this->_controller->getTranslate()->translate('labelsSettingsSectionItemsPerPage'), 5 => 5, 10 => 10, 20 => 20, 50 => 50, 100 => 100);
         $e = new Sitengine_Form_Element(Sitengine_Env::PARAM_IPP, $valueIpp);
         $e->setId('settings' . Sitengine_Env::PARAM_IPP);
         $e->setClass('settingsSelect');
         $settingsElements[Sitengine_Env::PARAM_IPP] = $e->getSelect($ippValues);
         $hiddens = array(Sitengine_Env::PARAM_PARENTID => $this->_controller->getEntity()->getParentId(), Sitengine_Env::PARAM_SORT => $sorting->getActiveRule(), Sitengine_Env::PARAM_ORDER => $sorting->getActiveOrder());
         foreach ($hiddens as $k => $v) {
             $hiddens[$k] = Sitengine_Form_Element::getHidden($k, $v);
         }
         $settingsData = array('isActive' => $settingsIsActive, 'hiddens' => implode('', $hiddens), 'ELEMENTS' => $settingsElements);
         ########################################################################
         #### FILTER
         ########################################################################
         $e = new Sitengine_Form_Element(Sitengine_Sitemap_Backend_Controller::PARAM_FILTER_BY_TYPE, $filter->getVal(Sitengine_Sitemap_Backend_Controller::PARAM_FILTER_BY_TYPE));
         $e->setId('filter' . Sitengine_Sitemap_Backend_Controller::PARAM_FILTER_BY_TYPE);
         $e->setClass('filterSelect');
         $filter->setElement(Sitengine_Sitemap_Backend_Controller::PARAM_FILTER_BY_TYPE, $e->getSelect($this->_controller->getTranslate()->translateGroup('fieldValsFilterByType')->toArray()));
         $e = new Sitengine_Form_Element(Sitengine_Sitemap_Backend_Controller::PARAM_FILTER_BY_FIND, $filter->getVal(Sitengine_Sitemap_Backend_Controller::PARAM_FILTER_BY_FIND));
         $e->setId('filter' . Sitengine_Sitemap_Backend_Controller::PARAM_FILTER_BY_FIND);
         $e->setClass('filterText');
         $filter->setElement(Sitengine_Sitemap_Backend_Controller::PARAM_FILTER_BY_FIND, $e->getText(20));
         $hiddens = array(Sitengine_Env::PARAM_PARENTID => $this->_controller->getEntity()->getParentId(), Sitengine_Env::PARAM_SORT => $sorting->getActiveRule(), Sitengine_Env::PARAM_ORDER => $sorting->getActiveOrder());
         foreach ($hiddens as $k => $v) {
             $hiddens[$k] = Sitengine_Form_Element::getHidden($k, $v);
         }
         $args = array(Sitengine_Env::PARAM_ACTION => $this->_controller->getRequest()->getActionName(), Sitengine_Env::PARAM_PARENTID => $this->_controller->getEntity()->getParentId(), Sitengine_Env::PARAM_SORT => $sorting->getActiveRule(), Sitengine_Env::PARAM_ORDER => $sorting->getActiveOrder(), Sitengine_Sitemap_Backend_Controller::PARAM_FILTER_RESET => 1);
         $route = $this->_controller->getFrontController()->getRouter()->getRoute(Sitengine_Sitemap_Backend_Front::ROUTE_INDEX);
         $uriReset = $this->_controller->getRequest()->getBasePath() . '/' . $route->assemble($args, true);
         $filterData = array('isActive' => $filter->isActive(), 'uriReset' => $uriReset, 'hiddens' => implode('', $hiddens), 'ELEMENTS' => $filter->getElements());
         ########################################################################
         #### SORTING
         ########################################################################
         $queries = array();
         foreach ($sorting->getOrdering() as $field => $order) {
             $args = array(Sitengine_Env::PARAM_ACTION => $this->_controller->getRequest()->getActionName(), Sitengine_Env::PARAM_PARENTID => $this->_controller->getEntity()->getParentId(), Sitengine_Env::PARAM_SORT => $field, Sitengine_Env::PARAM_ORDER => $order);
             $route = $this->_controller->getFrontController()->getRouter()->getRoute(Sitengine_Sitemap_Backend_Front::ROUTE_INDEX);
             $queries[$field] = $this->_controller->getRequest()->getBasePath() . '/' . $route->assemble($args, true);
         }
         $sortingData = array('QUERIES' => $queries, 'COLUMNS' => $sorting->getColumns());
         ########################################################################
         #### PAGER
         ########################################################################
         $pager = new Sitengine_Grid_Pager($valuePage, $valueIpp);
         ########################################################################
         #### LISTQUERY
         ########################################################################
         $q = 'SELECT';
         $q .= ' id,';
         $q .= ' locked,';
         #$q .= ' enabled,';
         $q .= ' cdate,';
         $q .= ' mdate,';
         $q .= ' keyword,';
         $q .= ' type,';
         $q .= ' file1OriginalName,';
         $q .= ' file1OriginalSource,';
         $q .= ' file1ThumbnailName,';
         $q .= ' file1ThumbnailWidth,';
         $q .= ' file1ThumbnailHeight,';
         $q .= ' file1ThumbnailMime,';
         $q .= ' file1ThumbnailSize,';
         $q .= ' IF(htmlLang' . $this->_controller->getTranscripts()->getIndex() . '="", htmlLang' . $this->_controller->getTranscripts()->getDefaultIndex() . ', htmlLang' . $this->_controller->getTranscripts()->getIndex() . ') AS html,';
         $q .= ' IF(htmlLang' . $this->_controller->getTranscripts()->getIndex() . '="", 1, 0) AS transcriptMissing';
         $q .= ' FROM';
         $q .= ' ' . $this->_controller->getFrontController()->getSitemapPackage()->getTableSitemap();
         $q .= ' WHERE';
         $q .= ' pid = "' . $this->_controller->getEntity()->getParentId() . '"';
         #$q .= ' AND '.Sitengine_Permiso::FIELD_OID.' = "'.$this->_controller->getPermiso()->getOrganization()->getId().'"';
         $q .= $filter->getSql();
         $q .= $this->_controller->getPermiso()->getDac()->getReadAccessSql($this->_controller->getAuthorizedGroups());
         $q .= $sorting->getClause(true);
         $sql = $this->_controller->getDatabase()->limit($q, $valueIpp, $pager->getOffset());
         $statement = $this->_controller->getDatabase()->prepare($sql);
         $statement->execute();
         $list = $statement->fetchAll();
         if ($pager->getCurrPage() > 1 && !sizeof($list)) {
             # current page is out of bounds - go to beginning of list
             $pager = new Sitengine_Grid_Pager(1, $valueIpp);
             $sql = $this->_controller->getDatabase()->limit($q, $valueIpp, 0);
             $statement = $this->_controller->getDatabase()->prepare($sql);
             $statement->execute();
             $list = $statement->fetchAll();
         }
         #print $sql;
         #Sitengine_Debug::print_r($list);
         # count full result
         $q = preg_replace('/SELECT .* FROM/', 'SELECT COUNT(*) AS count FROM', $q);
         $q = preg_replace('/ORDER BY .*/', '', $q);
         $statement = $this->_controller->getDatabase()->prepare($q);
         $statement->execute();
         $result = $statement->fetchAll();
         $pager->calculate($result[0]['count']);
         ########################################################################
         #### LISTDATA
         ########################################################################
         $markedRows = $this->_controller->getMarkedRows();
         foreach ($list as $count => $row) {
             # row selector checkbox
             if ($row['locked']) {
                 $row['rowSelectCheckbox'] = '&nbsp;';
             } else {
                 $p = 'SELECTROWITEM' . $row['id'];
                 $s = sizeof($markedRows) && isset($markedRows[$row['id']]) ? $this->_controller->getRequest()->getPost($p) : 0;
                 $e = new Sitengine_Form_Element($p, 1);
                 $e->setClass('listformCheckbox');
                 $row['rowSelectCheckbox'] = $e->getCheckbox($s);
             }
             $n = 'locked';
             $p = 'UPDATEROWITEM' . $n . 'ITEMID' . $row['id'];
             $h = 'UPDATEROWITEMCURRENT' . $n . 'ITEMID' . $row['id'];
             $s = sizeof($markedRows) && isset($markedRows[$row['id']]) ? $this->_controller->getRequest()->getPost($p) : $row[$n];
             $e = new Sitengine_Form_Element($p, 1);
             $e->setClass('listformCheckbox');
             $locked = $e->getCheckbox($s);
             $locked .= Sitengine_Form_Element::getHidden($h, $row[$n]);
             /*
             if($row['type']==Sitengine_Sitemap::ITEMTYPE_LAYER) { $enabled = '&nbsp;'; }
             else {
             					$n = 'enabled';
             					$p = 'UPDATEROWITEM'.$n.'ITEMID'.$row['id'];
             					$h = 'UPDATEROWITEMCURRENT'.$n.'ITEMID'.$row['id'];
             					$s = (sizeof($markedRows) && isset($markedRows[$row['id']])) ? $this->_controller->getRequest()->getPost($p) : $row[$n];
             					$e = new Sitengine_Form_Element($p, 1);
             					$e->setClass('listformCheckbox');
             					$enabled  = $e->getCheckbox($s);
             					$enabled .= Sitengine_Form_Element::getHidden($h, $row[$n]);
             }
             */
             $row['childCount'] = 0;
             $row['fileCount'] = 0;
             $row['indexAction'] = '';
             # uris
             switch ($row['type']) {
                 case Sitengine_Sitemap::ITEMTYPE_FILE:
                     $updateDirective = Sitengine_Sitemap_Backend_Controller::ACTION_UPDATEFILE;
                     break;
                 case Sitengine_Sitemap::ITEMTYPE_PAGE:
                     $updateDirective = Sitengine_Sitemap_Backend_Controller::ACTION_UPDATEPAGE;
                     break;
                 case Sitengine_Sitemap::ITEMTYPE_MASK:
                     $updateDirective = Sitengine_Sitemap_Backend_Controller::ACTION_UPDATEMASK;
                     break;
                 case Sitengine_Sitemap::ITEMTYPE_LAYER:
                     $updateDirective = Sitengine_Sitemap_Backend_Controller::ACTION_UPDATELAYER;
                     break;
                 case Sitengine_Sitemap::ITEMTYPE_SNIPPET:
                     $updateDirective = Sitengine_Sitemap_Backend_Controller::ACTION_UPDATESNIPPET;
                     break;
             }
             $args = array(Sitengine_Env::PARAM_ACTION => $updateDirective, Sitengine_Env::PARAM_ID => $row['id']);
             $route = $this->_controller->getFrontController()->getRouter()->getRoute(Sitengine_Sitemap_Backend_Front::ROUTE_INDEX);
             $uriUpdate = $this->_controller->getRequest()->getBasePath() . '/' . $route->assemble($args, true);
             $args = array(Sitengine_Env::PARAM_ACTION => Sitengine_Sitemap_Backend_Controller::ACTION_INDEX, Sitengine_Env::PARAM_PARENTID => $row['id']);
             $route = $this->_controller->getFrontController()->getRouter()->getRoute(Sitengine_Sitemap_Backend_Front::ROUTE_INDEX);
             $uriChildIndex = $this->_controller->getRequest()->getBasePath() . '/' . $route->assemble($args, true);
             $args = array(Sitengine_Env::PARAM_ACTION => Sitengine_Sitemap_Backend_Controller::ACTION_NEWPAGE, Sitengine_Env::PARAM_PARENTID => $row['id']);
             $route = $this->_controller->getFrontController()->getRouter()->getRoute(Sitengine_Sitemap_Backend_Front::ROUTE_INDEX);
             $uriChildNewPage = $this->_controller->getRequest()->getBasePath() . '/' . $route->assemble($args, true);
             $args = array(Sitengine_Env::PARAM_ACTION => Sitengine_Sitemap_Backend_Controller::ACTION_NEWFILE, Sitengine_Env::PARAM_PARENTID => $row['id']);
             $route = $this->_controller->getFrontController()->getRouter()->getRoute(Sitengine_Sitemap_Backend_Front::ROUTE_INDEX);
             $uriChildNewFile = $this->_controller->getRequest()->getBasePath() . '/' . $route->assemble($args, true);
             $args = array(Sitengine_Env::PARAM_ACTION => Sitengine_Sitemap_Backend_Controller::ACTION_NEWMASK, Sitengine_Env::PARAM_PARENTID => $row['id']);
             $route = $this->_controller->getFrontController()->getRouter()->getRoute(Sitengine_Sitemap_Backend_Front::ROUTE_INDEX);
             $uriChildNewMask = $this->_controller->getRequest()->getBasePath() . '/' . $route->assemble($args, true);
             $args = array(Sitengine_Env::PARAM_ACTION => Sitengine_Sitemap_Backend_Controller::ACTION_NEWLAYER, Sitengine_Env::PARAM_PARENTID => $row['id']);
             $route = $this->_controller->getFrontController()->getRouter()->getRoute(Sitengine_Sitemap_Backend_Front::ROUTE_INDEX);
             $uriChildNewLayer = $this->_controller->getRequest()->getBasePath() . '/' . $route->assemble($args, true);
             $args = array(Sitengine_Env::PARAM_ACTION => Sitengine_Sitemap_Backend_Controller::ACTION_NEWSNIPPET, Sitengine_Env::PARAM_PARENTID => $row['id']);
             $route = $this->_controller->getFrontController()->getRouter()->getRoute(Sitengine_Sitemap_Backend_Front::ROUTE_INDEX);
             $uriChildNewSnippet = $this->_controller->getRequest()->getBasePath() . '/' . $route->assemble($args, true);
             if ($row['type'] == Sitengine_Sitemap::ITEMTYPE_PAGE || $row['type'] == Sitengine_Sitemap::ITEMTYPE_MASK) {
                 $row['childCount'] = $this->_controller->getViewHelper()->countChildren($row['id']);
                 $indexActions = array('' => $this->_controller->getTranslate()->translate('labelsListformElementActionTitleFiles') . ' (' . $row['childCount'] . ')', $uriUpdate => $this->_controller->getTranslate()->translate('labelsListformElementActionUpdate'), $uriChildIndex => $this->_controller->getTranslate()->translate('labelsListformElementActionChildIndex'), $uriChildNewFile => $this->_controller->getTranslate()->translate('labelsListformElementActionNewFile'), $uriChildNewSnippet => $this->_controller->getTranslate()->translate('labelsListformElementActionNewSnippet'));
                 $e = new Sitengine_Form_Element('functions_' . $row['id'], '');
                 $e->setScript('onchange="window.location=this.options[this.selectedIndex].value;"');
                 $e->setClass('listformSelect');
                 $e->setId('listform' . $n);
                 $row['indexAction'] = $e->getSelect($indexActions);
             } else {
                 if ($row['type'] == Sitengine_Sitemap::ITEMTYPE_LAYER) {
                     $row['childCount'] = $this->_controller->getViewHelper()->countChildren($row['id']);
                     $indexActions = array('' => $this->_controller->getTranslate()->translate('labelsListformElementActionTitle') . ' (' . $row['childCount'] . ')', $uriUpdate => $this->_controller->getTranslate()->translate('labelsListformElementActionUpdate'), $uriChildIndex => $this->_controller->getTranslate()->translate('labelsListformElementActionChildIndex'), $uriChildNewLayer => $this->_controller->getTranslate()->translate('labelsListformElementActionNewLayer'), $uriChildNewPage => $this->_controller->getTranslate()->translate('labelsListformElementActionNewPage'), $uriChildNewSnippet => $this->_controller->getTranslate()->translate('labelsListformElementActionNewSnippet'), $uriChildNewFile => $this->_controller->getTranslate()->translate('labelsListformElementActionNewFile'));
                     $e = new Sitengine_Form_Element('functions_' . $row['id'], '');
                     $e->setScript('onchange="window.location=this.options[this.selectedIndex].value;"');
                     $e->setClass('listformSelect');
                     $e->setId('listform' . $n);
                     $row['indexAction'] = $e->getSelect($indexActions);
                 }
             }
             $row['isMarked'] = isset($markedRows[$row['id']]) ? $markedRows[$row['id']] : 0;
             $row['lockedCheckbox'] = $locked;
             #$row['enabledCheckbox'] = $enabled;
             $row['uriUpdate'] = $uriUpdate;
             $row['uriChildIndex'] = $uriChildIndex;
             $name = 'cdate';
             $date = new Zend_Date($row[$name], Zend_Date::ISO_8601, $this->_controller->getLocale());
             $date->setTimezone($this->_controller->getPreferences()->getTimezone());
             $row[$name] = $date->get(Zend_Date::DATE_LONG, $this->_controller->getLocale()) . ' ';
             $row[$name] .= $date->get(Zend_Date::TIME_LONG, $this->_controller->getLocale());
             $list[$count] = $row;
         }
         ########################################################################
         #### PAGER DATA
         ########################################################################
         $hiddens = array(Sitengine_Env::PARAM_PARENTID => $this->_controller->getEntity()->getParentId(), Sitengine_Env::PARAM_SORT => $sorting->getActiveRule(), Sitengine_Env::PARAM_ORDER => $sorting->getActiveOrder());
         foreach ($hiddens as $k => $v) {
             $hiddens[$k] = Sitengine_Form_Element::getHidden($k, $v);
         }
         $args = array(Sitengine_Env::PARAM_ACTION => $this->_controller->getRequest()->getActionName(), Sitengine_Env::PARAM_PARENTID => $this->_controller->getEntity()->getParentId(), Sitengine_Env::PARAM_SORT => $sorting->getActiveRule(), Sitengine_Env::PARAM_ORDER => $sorting->getActiveOrder(), Sitengine_Env::PARAM_PAGE => $pager->getPrevPage());
         $route = $this->_controller->getFrontController()->getRouter()->getRoute(Sitengine_Sitemap_Backend_Front::ROUTE_INDEX);
         $uriPrevPage = $this->_controller->getRequest()->getBasePath() . '/' . $route->assemble($args, true);
         $args = array(Sitengine_Env::PARAM_ACTION => $this->_controller->getRequest()->getActionName(), Sitengine_Env::PARAM_PARENTID => $this->_controller->getEntity()->getParentId(), Sitengine_Env::PARAM_SORT => $sorting->getActiveRule(), Sitengine_Env::PARAM_ORDER => $sorting->getActiveOrder(), Sitengine_Env::PARAM_PAGE => $pager->getNextPage());
         $route = $this->_controller->getFrontController()->getRouter()->getRoute(Sitengine_Sitemap_Backend_Front::ROUTE_INDEX);
         $uriNextPage = $this->_controller->getRequest()->getBasePath() . '/' . $route->assemble($args, true);
         $currPageInput = new Sitengine_Form_Element(Sitengine_Env::PARAM_PAGE, $pager->getCurrPage());
         $currPageInput->setClass('pagerInput');
         $pagerData = array('hiddens' => implode('', $hiddens), 'currPageInput' => $currPageInput->getText(2), 'currPage' => $pager->getCurrPage(), 'nextPage' => $pager->getNextPage(), 'prevPage' => $pager->getPrevPage(), 'numPages' => $pager->getNumPages(), 'numItems' => $pager->getNumItems(), 'firstItem' => $pager->getFirstItem(), 'lastItem' => $pager->getLastItem(), 'uriPrevPage' => $uriPrevPage, 'uriNextPage' => $uriNextPage);
         ########################################################################
         #### URIS
         ########################################################################
         $args = array(Sitengine_Env::PARAM_PARENTID => $this->_controller->getEntity()->getParentId(), Sitengine_Env::PARAM_ACTION => Sitengine_Sitemap_Backend_Controller::ACTION_DOBATCHDELETE);
         $route = $this->_controller->getFrontController()->getRouter()->getRoute(Sitengine_Sitemap_Backend_Front::ROUTE_INDEX);
         $uriDoBatchDelete = $this->_controller->getRequest()->getBasePath() . '/' . $route->assemble($args, true);
         $args = array(Sitengine_Env::PARAM_PARENTID => $this->_controller->getEntity()->getParentId(), Sitengine_Env::PARAM_ACTION => Sitengine_Sitemap_Backend_Controller::ACTION_DOBATCHUPDATE);
         $route = $this->_controller->getFrontController()->getRouter()->getRoute(Sitengine_Sitemap_Backend_Front::ROUTE_INDEX);
         $uriDoBatchUpdate = $this->_controller->getRequest()->getBasePath() . '/' . $route->assemble($args, true);
         $uris = array('submitDoBatchDelete' => $uriDoBatchDelete, 'submitDoBatchUpdate' => $uriDoBatchUpdate);
         ########################################################################
         #### COLLECT ALL DATA
         ########################################################################
         $hiddens = array(Sitengine_Env::PARAM_PAGE => $valuePage, Sitengine_Env::PARAM_SORT => $sorting->getActiveRule(), Sitengine_Env::PARAM_ORDER => $sorting->getActiveOrder());
         foreach ($hiddens as $k => $v) {
             $hiddens[$k] = Sitengine_Form_Element::getHidden($k, $v);
         }
         $formTitle = $this->_controller->getEntity()->isRootLevel() ? 'listformRootTitle' : 'listformTitle';
         return array('hiddens' => implode('', $hiddens), 'title' => $this->_controller->getTranslate()->translate('labels' . ucfirst($formTitle)), 'URIS' => $uris, 'FILTER' => $filterData, 'SETTINGS' => $settingsData, 'SORTING' => $sortingData, 'DATA' => $list, 'PAGER' => $pagerData);
     } catch (Exception $exception) {
         require_once 'Sitengine/Sitemap/Backend/Exception.php';
         throw new Sitengine_Sitemap_Backend_Exception('list page error', $exception);
     }
 }
Пример #8
0
 protected function _getMainSection()
 {
     try {
         require_once 'Sitengine/Form/Element.php';
         $valuePage = $this->_controller->getRequest()->get(Sitengine_Env::PARAM_PAGE);
         $table = $this->_controller->getFrontController()->getPermiso()->getMembershipsTable();
         $sorting = $table->getUserJoinSortingInstance($this->_controller->getRequest()->get(Sitengine_Env::PARAM_SORT), $this->_controller->getRequest()->get(Sitengine_Env::PARAM_ORDER));
         ########################################################################
         #### SETTINGS
         ########################################################################
         $settingsIsActive = false;
         ### ipp ###
         $defaultIpp = 20;
         $valueIpp = $this->_controller->getPreferences()->getItemsPerPage();
         $valueIpp = is_numeric($valueIpp) ? $valueIpp : $defaultIpp;
         $valueIpp = $valueIpp <= 100 && $valueIpp >= 1 ? $valueIpp : $defaultIpp;
         $ippValues = array('' => $this->_controller->getTranslate()->translate('indexViewSettingsSectionItemsPerPage'), 5 => 5, 10 => 10, 20 => 20, 50 => 50, 100 => 100);
         $hiddens = array(Sitengine_Env::PARAM_SORT => $sorting->getActiveRule(), Sitengine_Env::PARAM_ORDER => $sorting->getActiveOrder());
         foreach ($hiddens as $k => $v) {
             $hiddens[$k] = Sitengine_Form_Element::getHidden($k, $v);
         }
         $settingsData = array('isActive' => $settingsIsActive, 'hiddens' => implode('', $hiddens), 'IPPS' => $ippValues, Sitengine_Env::PARAM_IPP => $valueIpp);
         ########################################################################
         #### FILTER
         ########################################################################
         $filter = $table->getUserJoinFilterInstance($this->_controller->getRequest(), array('find' => Sitengine_Permiso_Backend_Groups_Members_Controller::PARAM_FILTER_BY_FIND, 'reset' => Sitengine_Permiso_Backend_Groups_Members_Controller::PARAM_FILTER_RESET), $this->_controller->getNamespace());
         $hiddens = array(Sitengine_Env::PARAM_SORT => $sorting->getActiveRule(), Sitengine_Env::PARAM_ORDER => $sorting->getActiveOrder());
         foreach ($hiddens as $k => $v) {
             $hiddens[$k] = Sitengine_Form_Element::getHidden($k, $v);
         }
         $args = array(Sitengine_Env::PARAM_ANCESTORID => $this->_controller->getEntity()->getAncestorId());
         $query = array(Sitengine_Env::PARAM_SORT => $sorting->getActiveRule(), Sitengine_Env::PARAM_ORDER => $sorting->getActiveOrder(), Sitengine_Permiso_Backend_Groups_Members_Controller::PARAM_FILTER_RESET => 1);
         $route = $this->_controller->getFrontController()->getRouter()->getRoute(Sitengine_Permiso_Backend_Front::ROUTE_GROUPS_MEMBERS);
         $uriReset = $this->_controller->getRequest()->getBasePath() . '/' . $route->assemble($args, true);
         $uriReset .= Sitengine_Controller_Request_Http::makeNameValueQuery($query);
         $filterData = array('isActive' => $filter->isActive(), 'uriReset' => $uriReset, 'hiddens' => implode('', $hiddens), 'DATA' => $filter->getData());
         ########################################################################
         #### SORTING
         ########################################################################
         $queries = array();
         foreach ($sorting->getOrdering() as $field => $order) {
             $args = array(Sitengine_Env::PARAM_ANCESTORID => $this->_controller->getEntity()->getAncestorId());
             $query = array(Sitengine_Env::PARAM_SORT => $field, Sitengine_Env::PARAM_ORDER => $order);
             $route = $this->_controller->getFrontController()->getRouter()->getRoute(Sitengine_Permiso_Backend_Front::ROUTE_GROUPS_MEMBERS);
             $queries[$field] = $this->_controller->getRequest()->getBasePath() . '/' . $route->assemble($args, true);
             $queries[$field] .= Sitengine_Controller_Request_Http::makeNameValueQuery($query);
         }
         $sortingData = array('QUERIES' => $queries, 'COLUMNS' => $sorting->getColumns());
         ########################################################################
         #### PAGER
         ########################################################################
         require_once 'Sitengine/Grid/Pager.php';
         $pager = new Sitengine_Grid_Pager($valuePage, $valueIpp);
         ########################################################################
         #### LISTQUERY
         ########################################################################
         $membershipsTableName = $this->_controller->getFrontController()->getPermiso()->getMembershipsTableName();
         $usersTableName = $this->_controller->getFrontController()->getPermiso()->getUsersTableName();
         $whereClauses = array($this->_controller->getDatabase()->quoteInto("{$membershipsTableName}.groupId = ?", $this->_controller->getEntity()->getAncestorId()), "{$membershipsTableName}.userId = {$usersTableName}.id", $filter->getSql(''));
         $select = $table->select()->setIntegrityCheck(false)->from($membershipsTableName)->from($usersTableName, array('name', 'nickname', 'firstname', 'lastname'))->order($sorting->getClause())->limit($valueIpp, $pager->getOffset());
         foreach ($whereClauses as $clause) {
             if ($clause) {
                 $select->where($clause);
             }
         }
         #print $select->__toString();
         $items = $table->fetchAll($select);
         #Sitengine_Debug::print_r($items->toArray());
         # if current page is out of bounds - go to beginning of list
         if (!$items->count() && $pager->getCurrPage() > 1) {
             $pager = new Sitengine_Grid_Pager(1, $valueIpp);
             $select = $table->select()->setIntegrityCheck(false)->from($membershipsTableName)->from($usersTableName, array('name', 'nickname', 'firstname', 'lastname'))->order($sorting->getClause())->limit($valueIpp, 0);
             foreach ($whereClauses as $clause) {
                 if ($clause) {
                     $select->where($clause);
                 }
             }
             $items = $table->fetchAll($select);
         }
         # count total number of records
         $select = $table->select()->setIntegrityCheck(false)->from($membershipsTableName, array('id'))->from($usersTableName, array('name'));
         foreach ($whereClauses as $clause) {
             if ($clause) {
                 $select->where($clause);
             }
         }
         $count = $table->fetchAll($select);
         $pager->calculate(sizeof($count));
         ########################################################################
         #### LISTDATA
         ########################################################################
         $markedRows = $this->_controller->getMarkedRows();
         $list = array();
         foreach ($items as $item) {
             $row = $table->complementRow($item);
             # row selector checkbox
             $row['rowSelectCheckbox'] = array();
             if (!$row['locked']) {
                 $name = 'SELECTROWITEM' . $row['id'];
                 $row['rowSelectCheckbox'] = array('name' => $name, 'checked' => sizeof($markedRows) && isset($markedRows[$row['id']]) ? $this->_controller->getRequest()->getPost($name) : 0);
             }
             $n = 'locked';
             $name = 'UPDATEROWITEM' . $n . 'ITEMID' . $row['id'];
             $current = 'UPDATEROWITEMCURRENT' . $n . 'ITEMID' . $row['id'];
             $row['lockedCheckbox'] = array('name' => $name, 'checked' => sizeof($markedRows) && isset($markedRows[$row['id']]) ? $this->_controller->getRequest()->getPost($name) : $row[$n], 'current' => Sitengine_Form_Element::getHidden($current, $row[$n]));
             # uris
             $args = array(Sitengine_Env::PARAM_ANCESTORID => $this->_controller->getEntity()->getAncestorId(), Sitengine_Env::PARAM_ID => $row['id']);
             $route = $this->_controller->getFrontController()->getRouter()->getRoute(Sitengine_Permiso_Backend_Front::ROUTE_GROUPS_MEMBERS_SHARP);
             $row['uriUpdate'] = $this->_controller->getRequest()->getBasePath() . '/' . $route->assemble($args, true);
             $row['isMarked'] = isset($markedRows[$row['id']]) ? $markedRows[$row['id']] : 0;
             $list[] = $row;
         }
         ########################################################################
         #### PAGER DATA
         ########################################################################
         $hiddens = array(Sitengine_Env::PARAM_SORT => $sorting->getActiveRule(), Sitengine_Env::PARAM_ORDER => $sorting->getActiveOrder());
         foreach ($hiddens as $k => $v) {
             $hiddens[$k] = Sitengine_Form_Element::getHidden($k, $v);
         }
         $args = array(Sitengine_Env::PARAM_ANCESTORID => $this->_controller->getEntity()->getAncestorId());
         $query = array(Sitengine_Env::PARAM_SORT => $sorting->getActiveRule(), Sitengine_Env::PARAM_ORDER => $sorting->getActiveOrder(), Sitengine_Env::PARAM_PAGE => $pager->getPrevPage());
         $route = $this->_controller->getFrontController()->getRouter()->getRoute(Sitengine_Permiso_Backend_Front::ROUTE_GROUPS_MEMBERS);
         $uriPrevPage = $this->_controller->getRequest()->getBasePath() . '/' . $route->assemble($args, true);
         $uriPrevPage .= Sitengine_Controller_Request_Http::makeNameValueQuery($query);
         $args = array(Sitengine_Env::PARAM_ANCESTORID => $this->_controller->getEntity()->getAncestorId());
         $query = array(Sitengine_Env::PARAM_SORT => $sorting->getActiveRule(), Sitengine_Env::PARAM_ORDER => $sorting->getActiveOrder(), Sitengine_Env::PARAM_PAGE => $pager->getNextPage());
         $route = $this->_controller->getFrontController()->getRouter()->getRoute(Sitengine_Permiso_Backend_Front::ROUTE_GROUPS_MEMBERS);
         $uriNextPage = $this->_controller->getRequest()->getBasePath() . '/' . $route->assemble($args, true);
         $uriNextPage .= Sitengine_Controller_Request_Http::makeNameValueQuery($query);
         $pagerData = array('hiddens' => implode('', $hiddens), 'currPage' => $pager->getCurrPage(), 'nextPage' => $pager->getNextPage(), 'prevPage' => $pager->getPrevPage(), 'numPages' => $pager->getNumPages(), 'numItems' => $pager->getNumItems(), 'firstItem' => $pager->getFirstItem(), 'lastItem' => $pager->getLastItem(), 'uriPrevPage' => $uriPrevPage, 'uriNextPage' => $uriNextPage);
         ########################################################################
         #### URIS
         ########################################################################
         $args = array(Sitengine_Env::PARAM_ANCESTORID => $this->_controller->getEntity()->getAncestorId());
         $route = $this->_controller->getFrontController()->getRouter()->getRoute(Sitengine_Permiso_Backend_Front::ROUTE_GROUPS_MEMBERS_BATCH);
         $uriDoBatchDelete = $this->_controller->getRequest()->getBasePath() . '/' . $route->assemble($args, true);
         $args = array(Sitengine_Env::PARAM_ANCESTORID => $this->_controller->getEntity()->getAncestorId());
         $route = $this->_controller->getFrontController()->getRouter()->getRoute(Sitengine_Permiso_Backend_Front::ROUTE_GROUPS_MEMBERS_BATCH);
         $uriDoBatchUpdate = $this->_controller->getRequest()->getBasePath() . '/' . $route->assemble($args, true);
         $uris = array('submitDoBatchDelete' => $uriDoBatchDelete, 'submitDoBatchUpdate' => $uriDoBatchUpdate);
         ########################################################################
         #### METHODS
         ########################################################################
         $methods = array('doBatchDelete' => Sitengine_Env::METHOD_DELETE, 'doBatchUpdate' => Sitengine_Env::METHOD_PUT);
         ########################################################################
         #### COLLECT ALL DATA
         ########################################################################
         $hiddens = array(Sitengine_Env::PARAM_METHOD => '', Sitengine_Env::PARAM_PAGE => $valuePage, Sitengine_Env::PARAM_SORT => $sorting->getActiveRule(), Sitengine_Env::PARAM_ORDER => $sorting->getActiveOrder());
         foreach ($hiddens as $k => $v) {
             $hiddens[$k] = Sitengine_Form_Element::getHidden($k, $v);
         }
         return array('hiddens' => implode('', $hiddens), 'title' => $this->_controller->getTranslate()->translate('indexViewTitle'), 'URIS' => $uris, 'METHODS' => $methods, 'FILTER' => $filterData, 'SETTINGS' => $settingsData, 'SORTING' => $sortingData, 'DATA' => $list, 'PAGER' => $pagerData);
     } catch (Exception $exception) {
         require_once 'Sitengine/Permiso/Backend/Groups/Members/Exception.php';
         throw new Sitengine_Permiso_Backend_Groups_Members_Exception('list page error', $exception);
     }
 }
Пример #9
0
 protected function _getMainSection()
 {
     try {
         $valuePage = $this->_controller->getRequest()->get(Sitengine_Env::PARAM_PAGE);
         $table = $this->_controller->getFrontController()->getBlogPackage()->getCommentsTable();
         $filter = $table->getFilterInstance($this->_controller->getRequest(), array('find' => Sitengine_Blog_Frontend_Blogs_Posts_Comments_Controller::PARAM_FILTER_BY_FIND, 'reset' => Sitengine_Blog_Frontend_Blogs_Posts_Comments_Controller::PARAM_FILTER_RESET), $this->_controller->getNamespace());
         $sorting = $table->getSortingInstance($this->_controller->getRequest()->get(Sitengine_Env::PARAM_SORT), $this->_controller->getRequest()->get(Sitengine_Env::PARAM_ORDER));
         ########################################################################
         #### SETTINGS
         ########################################################################
         $settingsIsActive = false;
         $settingsElements = array();
         ### ipp element ###
         $defaultIpp = 20;
         $valueIpp = $this->_controller->getPreferences()->getItemsPerPage();
         $valueIpp = is_numeric($valueIpp) ? $valueIpp : $defaultIpp;
         $valueIpp = $valueIpp <= 100 && $valueIpp >= 1 ? $valueIpp : $defaultIpp;
         # set html input element
         $ippValues = array('' => $this->_controller->getTranslate()->translate('labelsSettingsSectionItemsPerPage'), 5 => 5, 10 => 10, 20 => 20, 50 => 50, 100 => 100);
         $e = new Sitengine_Form_Element(Sitengine_Env::PARAM_IPP, $valueIpp);
         $e->setId('settings' . Sitengine_Env::PARAM_IPP);
         $e->setClass('settingsSelect');
         $settingsElements[Sitengine_Env::PARAM_IPP] = $e->getSelect($ippValues);
         $hiddens = array(Sitengine_Env::PARAM_SORT => $sorting->getActiveRule(), Sitengine_Env::PARAM_ORDER => $sorting->getActiveOrder());
         foreach ($hiddens as $k => $v) {
             $hiddens[$k] = Sitengine_Form_Element::getHidden($k, $v);
         }
         $settingsData = array('isActive' => $settingsIsActive, 'hiddens' => implode('', $hiddens), 'ELEMENTS' => $settingsElements);
         ########################################################################
         #### FILTER
         ########################################################################
         $e = new Sitengine_Form_Element(Sitengine_Blog_Frontend_Blogs_Posts_Comments_Controller::PARAM_FILTER_BY_FIND, $filter->getVal(Sitengine_Blog_Frontend_Blogs_Posts_Comments_Controller::PARAM_FILTER_BY_FIND));
         $e->setId('filter' . Sitengine_Blog_Frontend_Blogs_Posts_Comments_Controller::PARAM_FILTER_BY_FIND);
         $e->setClass('filterText');
         $filter->setElement(Sitengine_Blog_Frontend_Blogs_Posts_Comments_Controller::PARAM_FILTER_BY_FIND, $e->getText(20));
         $hiddens = array(Sitengine_Env::PARAM_SORT => $sorting->getActiveRule(), Sitengine_Env::PARAM_ORDER => $sorting->getActiveOrder());
         foreach ($hiddens as $k => $v) {
             $hiddens[$k] = Sitengine_Form_Element::getHidden($k, $v);
         }
         $args = array(Sitengine_Env::PARAM_GREATANCESTORID => $this->_controller->getEntity()->getGreatAncestorSlug(), Sitengine_Env::PARAM_ANCESTORID => $this->_controller->getEntity()->getAncestorId());
         $query = array(Sitengine_Env::PARAM_SORT => $sorting->getActiveRule(), Sitengine_Env::PARAM_ORDER => $sorting->getActiveOrder(), Sitengine_Blog_Frontend_Blogs_Posts_Comments_Controller::PARAM_FILTER_RESET => 1);
         $route = $this->_controller->getFrontController()->getRouter()->getRoute(Sitengine_Blog_Frontend_Front::ROUTE_BLOGS_POSTS_COMMENTS);
         $uriReset = $this->_controller->getRequest()->getBasePath() . '/' . $route->assemble($args, true);
         $uriReset .= Sitengine_Controller_Request_Http::makeNameValueQuery($query);
         $filterData = array('isActive' => $filter->isActive(), 'uriReset' => $uriReset, 'hiddens' => implode('', $hiddens), 'ELEMENTS' => $filter->getElements());
         ########################################################################
         #### SORTING
         ########################################################################
         $queries = array();
         foreach ($sorting->getOrdering() as $field => $order) {
             $args = array(Sitengine_Env::PARAM_GREATANCESTORID => $this->_controller->getEntity()->getGreatAncestorSlug(), Sitengine_Env::PARAM_ANCESTORID => $this->_controller->getEntity()->getAncestorId());
             $query = array(Sitengine_Env::PARAM_SORT => $field, Sitengine_Env::PARAM_ORDER => $order);
             $route = $this->_controller->getFrontController()->getRouter()->getRoute(Sitengine_Blog_Frontend_Front::ROUTE_BLOGS_POSTS_COMMENTS);
             $queries[$field] = $this->_controller->getRequest()->getBasePath() . '/' . $route->assemble($args, true);
             $queries[$field] .= Sitengine_Controller_Request_Http::makeNameValueQuery($query);
         }
         $sortingData = array('QUERIES' => $queries, 'COLUMNS' => $sorting->getColumns());
         ########################################################################
         #### PAGER
         ########################################################################
         $pager = new Sitengine_Grid_Pager($valuePage, $valueIpp);
         /*
         ########################################################################
         #### QUERY
         ########################################################################
         $table = $this->_controller->getFrontController()->getBlogPackage()->getCommentsTableName();
         
                 	$whereClauses = array(
                 		"$table.approve = '1'",
                 		"$table.parentId = '".$this->_controller->getEntity()->getAncestorId()."'",
                 		$this->_controller->getPermiso()->getDac()->getReadAccessSql($this->_controller->getFrontController()->getBlogPackage()->getAuthorizedGroups(), $table, false),
                 		$filter->getSql('')
                 	);
                 	
                 	$orderClause = $sorting->getClause(true);
                 	$items = $table->get($whereClauses, $orderClause, $valueIpp, $pager->getOffset());
                 	
                 	if($pager->getCurrPage() > 1 && !sizeof($items))
         			{
         				# current page is out of bounds - go to beginning of list
         				$pager = new Sitengine_Grid_Pager(1, $valueIpp);
         				$items = $table->get($whereClauses, $orderClause, $valueIpp, 0);
         			}
         			
         			$pager->calculate($table->count($whereClauses));
         */
         ########################################################################
         #### LISTQUERY
         ########################################################################
         $name = $this->_controller->getFrontController()->getBlogPackage()->getCommentsTableName();
         $usersTableName = $this->_controller->getPermiso()->getUsersTableName();
         $whereClauses = array("{$name}.approve = '1'", "{$name}.uid = {$usersTableName}.id", $this->_controller->getDatabase()->quoteInto('parentId = ?', $this->_controller->getEntity()->getAncestorId()), $filter->getSql(''));
         $select = $table->select()->setIntegrityCheck(false)->from($table)->from($usersTableName, array('name', 'firstname', 'lastname', 'nickname'))->order($sorting->getClause())->limit($valueIpp, $pager->getOffset());
         foreach ($whereClauses as $clause) {
             if ($clause) {
                 $select->where($clause);
             }
         }
         $items = $table->fetchAll($select);
         # if current page is out of bounds - go to beginning of list
         if (!$items->count() && $pager->getCurrPage() > 1) {
             $pager = new Sitengine_Grid_Pager(1, $valueIpp);
             $select = $table->select()->order($sorting->getClause())->limit($valueIpp, 0);
             foreach ($whereClauses as $clause) {
                 if ($clause) {
                     $select->where($clause);
                 }
             }
             $items = $table->fetchAll($select);
         }
         ########################################################################
         #### LISTDATA
         ########################################################################
         #$markedRows = $this->_controller->getMarkedRows();
         $list = array();
         foreach ($items as $item) {
             $row = $item->toArray();
             /*
             # row selector checkbox
             				$p = 'SELECTROWITEM'.$row['id'];
             				$s = (sizeof($markedRows) && isset($markedRows[$row['id']])) ? $this->_controller->getRequest()->getPost($p) : 0;
             				$e = new Sitengine_Form_Element($p, 1);
             				$e->setClass('listformCheckbox');
             				$row['rowSelectCheckbox'] = $e->getCheckbox($s);
             
             $n = 'approve';
             $p = 'UPDATEROWITEM'.$n.'ITEMID'.$row['id'];
             $h = 'UPDATEROWITEMCURRENT'.$n.'ITEMID'.$row['id'];
             $s = (sizeof($markedRows) && isset($markedRows[$row['id']])) ? $this->_controller->getRequest()->getPost($p) : $row[$n];
             $e = new Sitengine_Form_Element($p, 1);
             $e->setClass('listformCheckbox');
             $approve  = $e->getCheckbox($s);
             $approve .= Sitengine_Form_Element::getHidden($h, $row[$n]);
             
             # uris
             $args = array(
                 Sitengine_Env::PARAM_GREATANCESTORID => $this->_controller->getEntity()->getGreatAncestorSlug(),
             					Sitengine_Env::PARAM_ANCESTORID => $this->_controller->getEntity()->getAncestorId(),
             					Sitengine_Env::PARAM_ID => $row['id']
                 #Sitengine_Env::PARAM_PAGE => $valuePage,
                 #Sitengine_Env::PARAM_SORT => $sorting->getActiveRule(),
                 #Sitengine_Env::PARAM_ORDER => $sorting->getActiveOrder()
             );
             $route = $this->_controller->getFrontController()->getRouter()->getRoute(Sitengine_Blog_Frontend_Front::ROUTE_BLOGS_POSTS_COMMENTS_SHARP);
             $uriUpdate = $this->_controller->getRequest()->getBasePath().'/'.$route->assemble($args, true);
             
             $row['isMarked'] = (isset($markedRows[$row['id']])) ? $markedRows[$row['id']] : 0;
             $row['approveCheckbox'] = $approve;
             $row['uriUpdate'] = $uriUpdate;
             */
             #$row['cdate'] = $this->_controller->getViewHelper()->formatDate($row['cdate']);
             #$row['mdate'] = $this->_controller->getViewHelper()->formatDate($row['mdate']);
             $list[] = $row;
         }
         ########################################################################
         #### PAGER DATA
         ########################################################################
         $hiddens = array(Sitengine_Env::PARAM_SORT => $sorting->getActiveRule(), Sitengine_Env::PARAM_ORDER => $sorting->getActiveOrder());
         foreach ($hiddens as $k => $v) {
             $hiddens[$k] = Sitengine_Form_Element::getHidden($k, $v);
         }
         $args = array(Sitengine_Env::PARAM_GREATANCESTORID => $this->_controller->getEntity()->getGreatAncestorSlug(), Sitengine_Env::PARAM_ANCESTORID => $this->_controller->getEntity()->getAncestorId());
         $query = array(Sitengine_Env::PARAM_SORT => $sorting->getActiveRule(), Sitengine_Env::PARAM_ORDER => $sorting->getActiveOrder(), Sitengine_Env::PARAM_PAGE => $pager->getPrevPage());
         $route = $this->_controller->getFrontController()->getRouter()->getRoute(Sitengine_Blog_Frontend_Front::ROUTE_BLOGS_POSTS_COMMENTS);
         $uriPrevPage = $this->_controller->getRequest()->getBasePath() . '/' . $route->assemble($args, true);
         $uriPrevPage .= Sitengine_Controller_Request_Http::makeNameValueQuery($query);
         $args = array(Sitengine_Env::PARAM_GREATANCESTORID => $this->_controller->getEntity()->getGreatAncestorSlug(), Sitengine_Env::PARAM_ANCESTORID => $this->_controller->getEntity()->getAncestorId());
         $query = array(Sitengine_Env::PARAM_SORT => $sorting->getActiveRule(), Sitengine_Env::PARAM_ORDER => $sorting->getActiveOrder(), Sitengine_Env::PARAM_PAGE => $pager->getNextPage());
         $route = $this->_controller->getFrontController()->getRouter()->getRoute(Sitengine_Blog_Frontend_Front::ROUTE_BLOGS_POSTS_COMMENTS);
         $uriNextPage = $this->_controller->getRequest()->getBasePath() . '/' . $route->assemble($args, true);
         $uriNextPage .= Sitengine_Controller_Request_Http::makeNameValueQuery($query);
         $currPageInput = new Sitengine_Form_Element(Sitengine_Env::PARAM_PAGE, $pager->getCurrPage());
         $currPageInput->setClass('pagerInput');
         $pagerData = array('hiddens' => implode('', $hiddens), 'currPageInput' => $currPageInput->getText(2), 'currPage' => $pager->getCurrPage(), 'nextPage' => $pager->getNextPage(), 'prevPage' => $pager->getPrevPage(), 'numPages' => $pager->getNumPages(), 'numItems' => $pager->getNumItems(), 'firstItem' => $pager->getFirstItem(), 'lastItem' => $pager->getLastItem(), 'uriPrevPage' => $uriPrevPage, 'uriNextPage' => $uriNextPage);
         /*
         ########################################################################
         #### URIS
         ########################################################################
         $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_Frontend_Front::ROUTE_BLOGS_POSTS_COMMENTS_BATCH);
         $uriDoBatchDelete = $this->_controller->getRequest()->getBasePath().'/'.$route->assemble($args, true);
         
         $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_Frontend_Front::ROUTE_BLOGS_POSTS_COMMENTS_BATCH);
         $uriDoBatchUpdate = $this->_controller->getRequest()->getBasePath().'/'.$route->assemble($args, true);
         
         $uris = array(
         	'submitDoBatchDelete' => $uriDoBatchDelete,
         	'submitDoBatchUpdate' => $uriDoBatchUpdate
         );
         
         
         ########################################################################
         #### METHODS
         ########################################################################
         $methods = array(
         	'doBatchDelete' => Sitengine_Env::METHOD_DELETE,
         	'doBatchUpdate' => Sitengine_Env::METHOD_PUT
         );
         
         
         ########################################################################
         #### COLLECT ALL DATA
         ########################################################################
         $hiddens = array(
             Sitengine_Env::PARAM_METHOD => '',
             Sitengine_Env::PARAM_PAGE => $valuePage,
             Sitengine_Env::PARAM_SORT => $sorting->getActiveRule(),
             Sitengine_Env::PARAM_ORDER => $sorting->getActiveOrder()
         );
         foreach($hiddens as $k => $v) {
             $hiddens[$k] = Sitengine_Form_Element::getHidden($k, $v);
         }
         */
         return array('FILTER' => $filterData, 'SETTINGS' => $settingsData, 'SORTING' => $sortingData, 'DATA' => $list, 'PAGER' => $pagerData);
     } catch (Exception $exception) {
         require_once 'Sitengine/Blog/Frontend/Blogs/Posts/Comments/Exception.php';
         throw new Sitengine_Blog_Frontend_Blogs_Posts_Comments_Exception('list page error', $exception);
     }
 }
Пример #10
0
 protected function _getSlideSection()
 {
     try {
         $id = $this->_controller->getRequest()->getParam(Sitengine_Env::PARAM_ID);
         $parentId = $this->_controller->getRequest()->getParam(Sitengine_Env::PARAM_ANCESTORID);
         $table = $this->_controller->getFrontController()->getBlogPackage()->getFilesTable();
         /*
         $whereClauses = array(
         	"publish = '1'",
         	$this->_controller->getDatabase()->quoteInto('parentId = ?', $this->_controller->getEntity()->getAncestorId())
                 	);
         */
         $select = $table->select()->order('sorting ASC')->where("publish = '1'")->where('parentId = ?', $this->_controller->getEntity()->getAncestorId());
         /*
         foreach($whereClauses as $clause)
         {
         	if($clause) { $select->where($clause); }
         }
         */
         $items = $table->fetchAll($select);
         /*
         # count total number of records
         $select = $table->select()->from($table, array('COUNT(*) AS count'));
         #foreach($whereClauses as $clause) { if($clause) { $select->where($clause); } }
         $count = $table->fetchRow($select);
         $pager->calculate($count->count);
         
                 	$id = $this->_controller->getRequest()->getParam(Sitengine_Env::PARAM_ID);
                 	$parentId = $this->_controller->getRequest()->getParam(Sitengine_Env::PARAM_ANCESTORID);
                 	
                 	require_once 'Sitengine/Blog/Files.php';
                 	$filesObj = new Sitengine_Blog_Files(
                 		$this->_controller->getDatabase(),
                 		$this->_controller->getFrontController()->getBlogPackage()
                 	);
                 	$filesObj->setTranscript($this->_controller->getPreferences()->getLanguage());
                     $table = $this->_controller->getFrontController()->getBlogPackage()->getFilesTableName();
                     
                 	$whereClauses = array(
                 		"$table.parentId = '".$parentId."'",
                 		"$table.publish = '1'"
                 	);
                 	
                 	$orderClause = "ORDER BY $table.sorting ASC";
                 	$items = $filesObj->get($whereClauses, $orderClause);
         */
         $idFirst = null;
         $idLast = null;
         $idPrev = null;
         $idNext = null;
         $currItem = 1;
         $index = 1;
         foreach ($items as $row) {
             if ($row->id == $id) {
                 $currItem = $index;
                 break;
             }
             $index++;
         }
         #Sitengine_Debug::print_r($items);
         require_once 'Sitengine/Grid/Pager.php';
         $pager = new Sitengine_Grid_Pager($currItem, 1);
         $pager->calculate($items->count());
         $items->seek(0);
         $itemFirst = $table->complementRow($items->current());
         $items->seek($items->count() - 1);
         $itemLast = $table->complementRow($items->current());
         $items->seek($pager->getPrevPage() - 1);
         $itemPrev = $table->complementRow($items->current());
         $items->seek($pager->getNextPage() - 1);
         $itemNext = $table->complementRow($items->current());
         $items->seek($index - 1);
         $itemCurrent = $table->complementRow($items->current());
         return array('PREV' => $itemPrev, 'NEXT' => $itemNext, 'FIRST' => $itemFirst, 'LAST' => $itemLast, 'CURRENT' => $itemCurrent, 'idPrev' => $idPrev, 'idNext' => $idNext, 'idFirst' => $idFirst, 'idLast' => $idLast, 'currItem' => $currItem, 'numItems' => sizeof($items), 'uriPrev' => $this->_getSlideUri($parentId, $itemPrev['id']), 'uriNext' => $this->_getSlideUri($parentId, $itemNext['id']), 'uriFirst' => $this->_getSlideUri($parentId, $itemFirst['id']), 'uriLast' => $this->_getSlideUri($parentId, $itemLast['id']));
     } catch (Exception $exception) {
         require_once 'Sitengine/Blog/Frontend/Blogs/Posts/Files/Exception.php';
         throw new Sitengine_Blog_Frontend_Blogs_Posts_Files_Exception('slide section error', $exception);
     }
 }