diff --git a/application/modules/backend/controllers/StoreController.php b/application/modules/backend/controllers/StoreController.php index 7825f351a..e209079e8 100644 --- a/application/modules/backend/controllers/StoreController.php +++ b/application/modules/backend/controllers/StoreController.php @@ -1,309 +1,351 @@ . **/ class Backend_StoreController extends Local_Controller_Action_Backend { const RESULT_OK = "OK"; const RESULT_ERROR = "ERROR"; const DATA_ID_NAME = 'store_id'; /** @var Default_Model_DbTable_ConfigStore */ protected $_model; protected $_modelName = 'Default_Model_DbTable_ConfigStore'; protected $_pageTitle = 'Manage Store Config'; public function init() { $this->_model = new $this->_modelName(); $this->view->pageTitle = $this->_pageTitle; parent::init(); } public function indexAction() { } public function createAction() { $jTableResult = array(); try { $allParams = $this->getAllParams(); $resultWalk = array_walk($allParams, function (&$value) { $value = empty($value) ? null : $value; }); if (false === $resultWalk) { throw new Exception('array_walk through input parameters failed.'); } //$newRow = $this->_model->createRow($allParams); //$result = $newRow->save(); $newRow = $this->_model->save($allParams); $jTableResult['Result'] = self::RESULT_OK; $jTableResult['Record'] = $newRow->toArray(); } catch (Exception $e) { Zend_Registry::get('logger')->err(__METHOD__ . ' - ' . print_r($e, true)); $translate = Zend_Registry::get('Zend_Translate'); $jTableResult['Result'] = self::RESULT_ERROR; $jTableResult['Message'] = $translate->_('Error while processing data.'); } $this->_helper->json($jTableResult); } public function initcacheAction() { $allStoresCat = $this->_model->fetchAllStoresAndCategories(true); $allStoresConfig = $this->_model->fetchAllStoresConfigArray(true); $modelPCat = new Default_Model_ProjectCategory(); foreach ($allStoresConfig as $config) { $modelPCat->fetchCategoryTreeForStore($config['store_id'], true); $this->_model->fetchConfigForStore($config['store_id'], true); } } public function updateAction() { $jTableResult = array(); try { $values = $this->getAllParams(); foreach ($values as $key => $value) { if ($value == '') { $values[$key] = new Zend_Db_Expr('NULL'); } } // patch checkbox is_show_title get no parameter when is_show_title = 0 if(!isset($values['is_show_title'])){ $values['is_show_title'] = 0; } if(!isset($values['is_show_git_projects'])){ $values['is_show_git_projects'] = 0; } if(!isset($values['cross_domain_login'])){ $values['cross_domain_login'] = 0; } if(!isset($values['is_client'])){ $values['is_client'] = 0; } $record = $this->_model->save($values); $this->initCache($record->store_id); $tagsid = $this->getParam('tags_id', null); $tagmodel = new Default_Model_Tags(); $tagmodel->updateTagsPerStore($values['store_id'], $tagsid); + + $groupsid = $this->getParam('groups_id', null); + $groupmodel = new Default_Model_TagGroup(); + $groupmodel->updateTagGroupsPerStore($values['store_id'], $groupsid); + $jTableResult = array(); $jTableResult['Result'] = self::RESULT_OK; } catch (Exception $e) { Zend_Registry::get('logger')->err(__METHOD__ . ' - ' . print_r($e, true)); $translate = Zend_Registry::get('Zend_Translate'); $jTableResult['Result'] = self::RESULT_ERROR; $jTableResult['Message'] = $translate->_('Error while processing data.'); } $this->_helper->json($jTableResult); } protected function initCache($store_id) { $modelPCat = new Default_Model_ProjectCategory(); $modelPCat->fetchCategoryTreeForStore($store_id, true); $this->_model->fetchConfigForStore($store_id, true); $this->_model->fetchAllStoresAndCategories(true); $this->_model->fetchAllStoresConfigArray(true); } public function deleteAction() { $dataId = (int)$this->getParam(self::DATA_ID_NAME, null); $this->_model->deleteId($dataId); $this->cacheClear($dataId); $jTableResult = array(); $jTableResult['Result'] = self::RESULT_OK; $this->_helper->json($jTableResult); } protected function cacheClear($store_id) { /** @var Zend_Cache_Core $cache */ $cache = Zend_Registry::get('cache'); $cache->remove(Default_Model_ProjectCategory::CACHE_TREE_STORE . "_{$store_id}"); $cache->remove(Default_Model_DbTable_ConfigStore::CACHE_STORE_CONFIG . "_{$store_id}"); $this->_model->fetchAllStoresAndCategories(true); $this->_model->fetchAllStoresConfigArray(true); } public function listAction() { $startIndex = (int)$this->getParam('jtStartIndex'); $pageSize = (int)$this->getParam('jtPageSize'); $sorting = $this->getParam('jtSorting'); $filter['hostname'] = $this->getParam('filter_hostname'); $filter['category_id'] = $this->getParam('filter_category_id'); $select = $this->_model->select()->from($this->_model, array( '*', - 'tags_id' => new Zend_Db_Expr('(SELECT GROUP_CONCAT(CASE WHEN `tag`.`tag_fullname` IS NULL THEN `tag`.`tag_name` ELSE `tag`.`tag_fullname` END) + 'groups_id' => new Zend_Db_Expr('(SELECT GROUP_CONCAT(CASE WHEN `tag`.`tag_fullname` IS NULL THEN `tag`.`tag_name` ELSE `tag`.`tag_fullname` END) FROM `config_store_tag`,`tag` WHERE `tag`.`tag_id` = `config_store_tag`.`tag_id` AND `config_store_tag`.`store_id` = `config_store`.`store_id` GROUP BY `config_store_tag`.`store_id`) AS `tags_name`, (SELECT GROUP_CONCAT(`tag`.`tag_id`) FROM `config_store_tag`,`tag` WHERE `tag`.`tag_id` = `config_store_tag`.`tag_id` AND `config_store_tag`.`store_id` = `config_store`.`store_id` - GROUP BY `config_store_tag`.`store_id`)') + GROUP BY `config_store_tag`.`store_id`) AS `tags_id`, + (SELECT GROUP_CONCAT(`tag_group`.`group_name`) + FROM `config_store_tag_group`,`tag_group` + WHERE `tag_group`.`group_id` = `config_store_tag_group`.`tag_group_id` AND `config_store_tag_group`.`store_id` = `config_store`.`store_id` + GROUP BY `config_store_tag_group`.`store_id`) AS `groups_name`, + (SELECT GROUP_CONCAT(`tag_group`.`group_id`) + FROM `config_store_tag_group`,`tag_group` + WHERE `tag_group`.`group_id` = `config_store_tag_group`.`tag_group_id` AND `config_store_tag_group`.`store_id` = `config_store`.`store_id` + GROUP BY `config_store_tag_group`.`store_id`)') ))->order($sorting)->limit($pageSize, $startIndex)->setIntegrityCheck(false); foreach ($filter as $key => $value) { if (false === empty($value)) { $select->where("{$key} like ?", $value); } } $reports = $this->_model->fetchAll($select); $select = $this->_model->select()->from($this->_model)->setIntegrityCheck(false); foreach ($filter as $key => $value) { if (false === empty($value)) { $select->where("{$key} like ?", $value); } } $reportsAll = $this->_model->fetchAll($select->limit(null, null)->reset('columns') ->columns(array('countAll' => new Zend_Db_Expr('count(*)')))); $jTableResult = array(); $jTableResult['Result'] = self::RESULT_OK; $jTableResult['Records'] = $reports->toArray(); $jTableResult['TotalRecordCount'] = $reportsAll->current()->countAll; $this->_helper->json($jTableResult); } public function hostnamesAction() { $result = true; $id = (int)$this->getParam('c'); try { $records = $this->_model->fetchHostnamesForJTable($id); } catch (Exception $e) { Zend_Registry::get('logger')->err(__METHOD__ . ' - ' . print_r($e, true)); $result = false; $records = array(); } $jTableResult = array(); $jTableResult['Result'] = ($result == true) ? self::RESULT_OK : self::RESULT_ERROR; $jTableResult['Options'] = $records; $this->_helper->json($jTableResult); } public function loadstoreconfigAction() { $jTableResult = array(); try { $configStoreId = $this->getParam('c'); $modelConfig = new Backend_Model_ClientFileConfig($configStoreId); $modelConfig->loadClientConfig(); if ($modelConfig->getDefaultConfigLoaded()) { $this->view->defaultConfigLoaded = true; } $form = $modelConfig->getForm(); $this->view->formConfig = $form; $view = $this->view->render('store/configform.phtml'); $jTableResult = array(); $jTableResult['Result'] = self::RESULT_OK; $jTableResult['ViewRecord'] = $view; } catch (Exception $e) { Zend_Registry::get('logger')->err(__METHOD__ . ' - ' . print_r($e, true)); $translate = Zend_Registry::get('Zend_Translate'); $this->getResponse()->setHttpResponseCode(500); $jTableResult['Result'] = self::RESULT_ERROR; $jTableResult['Message'] = $translate->_('Error while processing data.'); } $this->_helper->json($jTableResult); } public function savestoreconfigAction() { $jTableResult = array(); try { $clientName = $this->getParam('clientname'); unset($_POST['clientname']); $modelConfig = new Backend_Model_ClientFileConfig($clientName); $modelConfig->saveClientConfig($_POST, $clientName); $jTableResult = array(); $jTableResult['Result'] = self::RESULT_OK; } catch (Exception $e) { Zend_Registry::get('logger')->err(__METHOD__ . ' - ' . print_r($e, true)); $translate = Zend_Registry::get('Zend_Translate'); $jTableResult['Result'] = self::RESULT_ERROR; $jTableResult['Message'] = $translate->_('Error while processing data.'); } $this->_helper->json($jTableResult); } public function tagsallAction() { $result = true; $tagmodel = new Default_Model_Tags(); try { $resultRows = $tagmodel->getAllTagsForStoreFilter(); $resultForSelect = array(); + $resultForSelect[] = array('DisplayText' => '', 'Value' => ''); foreach ($resultRows as $row) { $resultForSelect[] = array('DisplayText' => $row['tag_name'].'['.$row['tag_id'].']', 'Value' => $row['tag_id']); } } catch (Exception $e) { Zend_Registry::get('logger')->err(__METHOD__ . ' - ' . print_r($e, true)); $result = false; $records = array(); } $jTableResult = array(); $jTableResult['Result'] = ($result == true) ? self::RESULT_OK : self::RESULT_ERROR; $jTableResult['Options'] = $resultForSelect; $this->_helper->json($jTableResult); } + + + public function alltaggroupsAction() + { + + $result = true; + $tagmodel = new Default_Model_TagGroup(); + + try { + $resultRows = $tagmodel->fetchAllGroups(); + $resultForSelect = array(); + $resultForSelect[] = array('DisplayText' => '', 'Value' => ''); + foreach ($resultRows as $row) { + $resultForSelect[] = array('DisplayText' => $row['group_name'].'['.$row['group_id'].']', 'Value' => $row['group_id']); + } + + } catch (Exception $e) { + Zend_Registry::get('logger')->err(__METHOD__ . ' - ' . print_r($e, true)); + $result = false; + $records = array(); + } + + $jTableResult = array(); + $jTableResult['Result'] = ($result == true) ? self::RESULT_OK : self::RESULT_ERROR; + $jTableResult['Options'] = $resultForSelect; + + $this->_helper->json($jTableResult); + } } \ No newline at end of file diff --git a/application/modules/backend/views/scripts/store/index.phtml b/application/modules/backend/views/scripts/store/index.phtml index 7a52ef2d2..a44b5b522 100644 --- a/application/modules/backend/views/scripts/store/index.phtml +++ b/application/modules/backend/views/scripts/store/index.phtml @@ -1,414 +1,460 @@ . **/ ?>
diff --git a/application/modules/default/controllers/ExploreController.php b/application/modules/default/controllers/ExploreController.php index 25c53cf6f..571f50458 100644 --- a/application/modules/default/controllers/ExploreController.php +++ b/application/modules/default/controllers/ExploreController.php @@ -1,386 +1,441 @@ . **/ class ExploreController extends Local_Controller_Action_DomainSwitch { const DEFAULT_ORDER = 'latest'; const TAG_ISORIGINAL = 'original-product'; /** @var string */ protected $_browserTitlePrepend; public function init() { parent::init(); $this->_auth = Zend_Auth::getInstance(); } public function categoriesAction() { // Filter-Parameter $inputFilterParams['category'] = (int)$this->getParam('cat', null); $inputFilterParams['filter'] = (int)$this->getParam('fil', null); $inputFilterParams['order'] = preg_replace('/[^-a-zA-Z0-9_]/', '', $this->getParam('ord', self::DEFAULT_ORDER)); $inputFilterParams['selected'] = (int)$this->getParam('sel', $inputFilterParams['category']); $modelCategories = new Default_Model_DbTable_ProjectCategory(); $children = $modelCategories->fetchImmediateChildren($inputFilterParams['selected']); $selChild = $modelCategories->fetchElement($inputFilterParams['filter']); $response = $this->generateResponseMsg($children, $inputFilterParams, $selChild); $this->_helper->json($response); } private function generateResponseMsg($children, $inputParams, $selChild) { $result = array(); if (count($children) == 0) { return $result; } $helperBuildExploreUrl = new Default_View_Helper_BuildExploreUrl(); foreach ($children as $child) { $nodeSelectedState = ($inputParams['filter'] == $child['project_category_id']) ? true : false; if (1 == ($child['rgt'] - $child['lft'])) { $result[] = array( 'title' => $child['title'], 'key' => $child['project_category_id'], 'href' => $helperBuildExploreUrl->buildExploreUrl($inputParams['category'], $child['project_category_id'], $inputParams['order']), 'target' => '_top', 'selected' => $nodeSelectedState ); } else { $nodeHasChildren = (1 == ($child['rgt'] - $child['lft'])) ? false : true; $nodeIsSelectedSubCat = (($selChild['lft'] > $child['lft']) AND ($selChild['rgt'] < $child['rgt'])) ? true : false; $nodeExpandedState = false; $nodeChildren = null; if ($nodeHasChildren AND $nodeIsSelectedSubCat) { $nodeExpandedState = true; $modelCategories = new Default_Model_DbTable_ProjectCategory(); $immChildren = $modelCategories->fetchImmediateChildren($child['project_category_id']); $nodeChildren = $this->generateResponseMsg($immChildren, $inputParams, $selChild); } $result[] = array( 'title' => $child['title'], 'key' => $child['project_category_id'], 'folder' => true, 'lazy' => true, 'selected' => $nodeSelectedState, 'expanded' => $nodeExpandedState, 'href' => $helperBuildExploreUrl->buildExploreUrl($inputParams['category'], $child['project_category_id'], $inputParams['order']), 'target' => '_top', 'children' => $nodeChildren ); } } return $result; } /** * @throws Zend_Cache_Exception * @throws Zend_Db_Select_Exception * @throws Zend_Exception * @throws Zend_Loader_PluginLoader_Exception * @throws Zend_Paginator_Exception */ public function indexAction() { // Filter-Parameter $inputFilterOriginal = $this->getParam('filteroriginal', $this->getFilterOriginalFromCookie()); $this->storeFilterOriginalInCookie($inputFilterOriginal); $this->view->inputFilterOriginal = $inputFilterOriginal; $inputCatId = (int)$this->getParam('cat', null); if ($inputCatId) { // $this->view->isFilterCat = true; // $this->view->filterCat = $inputCatId; $this->view->catabout = $this->getCategoryAbout($inputCatId); $helperFetchCategory = new Default_View_Helper_CatTitle(); $catTitle = $helperFetchCategory->catTitle($inputCatId); $this->view->headTitle($catTitle . ' - ' . $_SERVER['HTTP_HOST'], 'SET'); } $this->view->cat_id = $inputCatId; $storeCatIds = Zend_Registry::isRegistered('store_category_list') ? Zend_Registry::get('store_category_list') : null; $filter = array(); $filter['category'] = $inputCatId ? $inputCatId : $storeCatIds; $filter['order'] = preg_replace('/[^-a-zA-Z0-9_]/', '', $this->getParam('ord', self::DEFAULT_ORDER)); $filter['original'] = $inputFilterOriginal == 1 ? self::TAG_ISORIGINAL : null; + $filter['tag'] = Zend_Registry::isRegistered('config_store_tags') ? Zend_Registry::get('config_store_tags') : null; if (APPLICATION_ENV == "development") { Zend_Registry::get('logger')->debug(__METHOD__ . ' - ' . json_encode($filter)); } $tagFilter = Zend_Registry::isRegistered('config_store_tags') ? Zend_Registry::get('config_store_tags') : null; + + + $tagGroupFilter = Zend_Registry::isRegistered('config_store_taggroups') ? Zend_Registry::get('config_store_taggroups') : null; + if(!empty($tagGroupFilter)) { + $filterArray = array(); + foreach ($tagGroupFilter as $tagGroupId) { + $inputFilter = $this->getFilterTagFromCookie($tagGroupId); + $filterArray[$tagGroupId] = $inputFilter; + if(!empty($inputFilter)) { + $filter['tag'][] = $inputFilter; + } + } + $this->view->tag_group_filter = $filterArray; + } + + $page = (int)$this->getParam('page', 1); $storeConfig = Zend_Registry::isRegistered('store_config') ? Zend_Registry::get('store_config') : null; if ($storeConfig->layout_explore && $storeConfig->isRenderReact()) { $pageLimit = 50; $requestedElements = $this->fetchRequestedElements($filter, $pageLimit, ($page - 1) * $pageLimit); $this->view->productsJson = Zend_Json::encode($requestedElements['elements']); $this->view->filtersJson = Zend_Json::encode($filter); $this->view->cat_idJson = Zend_Json::encode($inputCatId); $modelInfo = new Default_Model_Info(); $topprods = $modelInfo->getMostDownloaded(100, $inputCatId, $tagFilter); $this->view->topprodsJson = Zend_Json::encode($topprods); $comments = $modelInfo->getLatestComments(5, $inputCatId, $tagFilter); $this->view->commentsJson = Zend_Json::encode($comments); $modelCategory = new Default_Model_ProjectCategory(); $this->view->categoriesJson = Zend_Json::encode($modelCategory->fetchTreeForView()); $this->_helper->viewRenderer('index-react'); } else { $pageLimit = 10; $requestedElements = $this->fetchRequestedElements($filter, $pageLimit, ($page - 1) * $pageLimit); } $paginator = Local_Paginator::factory($requestedElements['elements']); $paginator->setItemCountPerPage($pageLimit); $paginator->setCurrentPageNumber($page); $paginator->setTotalItemCount($requestedElements['total_count']); $this->view->products = $paginator; $this->view->totalcount = $requestedElements['total_count']; $this->view->filters = $filter; $this->view->page = $page; $this->view->package_type = Zend_Registry::isRegistered('config_store_tags') ? Zend_Registry::get('config_store_tags') : null; $this->view->tags = $tagFilter; } /** * @param $inputCatId * * @return string|null * @throws Zend_Exception */ protected function getCategoryAbout($inputCatId) { $config = Zend_Registry::get('config'); $static_config = $config->settings->static; $include_path_cat = $static_config->include_path . 'category_about/' . $inputCatId . '.phtml'; if (file_exists($include_path_cat)) { return $include_path_cat; } return null; } /** * @param array $inputFilterParams * @param int $limit * @param int $offset * * @return array * @throws Zend_Cache_Exception * @throws Zend_Db_Select_Exception * @throws Zend_Exception */ private function fetchRequestedElements($inputFilterParams, $limit = null, $offset = null) { $modelProject = new Default_Model_Project(); $requestedElements = $modelProject->fetchProjectsByFilter($inputFilterParams, $limit, $offset); return $requestedElements; } /** * @throws Zend_Exception * @throws Zend_Paginator_Exception */ public function searchAction() { ini_set('memory_limit', '3072M'); $allDomainCatIds = Zend_Registry::isRegistered('store_category_list') ? Zend_Registry::get('store_category_list') : null; if (count($allDomainCatIds) == 0) { $allDomainCatIds = null; } if (isset($allDomainCatIds)) { $this->view->categories = $allDomainCatIds; } else { $modelCategories = new Default_Model_DbTable_ProjectCategory(); $this->view->categories = $modelCategories->fetchMainCatIdsOrdered(); } // Filter-Parameter $filterInput = new Zend_Filter_Input(array('*' => 'StringTrim', 'projectSearchText' => 'StripTags', 'page' => 'digits'), array( 'projectSearchText' => array( new Zend_Validate_StringLength(array('min' => 3, 'max' => 100)), 'presence' => 'required' ), 'page' => 'digits' ), $this->getAllParams()); if ($filterInput->hasInvalid()) { $this->_helper->viewRenderer('searchError'); $this->view->messages = $filterInput->getMessages(); return; } $inputFilterParams['projectSearchText'] = $filterInput->getUnescaped('projectSearchText'); $page = (int)$filterInput->getEscaped('page'); $config = Zend_Registry::get('config'); Zend_Search_Lucene_Search_QueryParser::setDefaultEncoding('utf-8'); Zend_Search_Lucene_Analysis_Analyzer::setDefault(new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8_CaseInsensitive()); $dataPath = $config->settings->search->path; $dataPath .= $this->getNameForStoreClient() . DIRECTORY_SEPARATOR; $index = Zend_Search_Lucene::open($dataPath); try { $hits = $index->find($inputFilterParams['projectSearchText'] . '*'); } catch (Zend_Search_Lucene_Exception $e) { Zend_Registry::get('logger')->err(__METHOD__ . ' - ' . $e->getMessage() . PHP_EOL . $e->getTraceAsString()); $hits = array(); } if (count($hits) == 0) { $this->_helper->viewRenderer('searchError'); $this->view->inputFilter = $inputFilterParams; $this->view->searchText = $inputFilterParams['projectSearchText']; return; } $results = $this->copyToArray($hits); $paginator = Zend_Paginator::factory($results); $paginator->setDefaultItemCountPerPage(10); $paginator->setCurrentPageNumber($page); $this->view->hitsCount = count($hits); $this->view->hits = $paginator; $this->view->page = $page; $this->view->inputFilter = $inputFilterParams; $this->view->searchText = $inputFilterParams['projectSearchText']; } /** * @param array $hits * * @return array */ protected function copyToArray($hits) { $returnArray = array(); /** @var $hit Zend_Search_Lucene_Search_QueryHit */ foreach ($hits as $hit) { $returnArray[] = $hit->getDocument(); } return $returnArray; } protected function _initResponseHeader() { $duration = 1800; // in seconds $expires = gmdate("D, d M Y H:i:s", time() + $duration) . " GMT"; $this->getResponse() ->setHeader('X-FRAME-OPTIONS', 'ALLOWALL', true) // ->setHeader('Last-Modified', $modifiedTime, true) ->setHeader('Expires', $expires, true)->setHeader('Pragma', 'no-cache', true) ->setHeader('Cache-Control', 'private, no-cache, must-revalidate', true) ; } /** * @param Zend_Config $static_config * @return string|null */ protected function getStoreAbout($static_config) { $include_path = $static_config->include_path . 'store_about/' . $this->view->filterStore . '.phtml'; if (file_exists($include_path)) { return $include_path; } return null; } /** * @param array $elements * * @return array with additional info's * @deprecated */ private function fetchAdditionalData($elements) { $modelProject = new Default_Model_Project(); $requestedElements = Array(); foreach ($elements as $project) { $info = $modelProject->fetchProductInfo($project['project_id']); $requestedElements[] = $info; } return $requestedElements; } protected function setLayout() { $layoutName = 'flat_ui_template'; $storeConfig = Zend_Registry::isRegistered('store_config') ? Zend_Registry::get('store_config') : null; if($storeConfig && $storeConfig->layout_explore) { $this->_helper->layout()->setLayout($storeConfig->layout_explore); }else{ $this->_helper->layout()->setLayout($layoutName); } } private function storeFilterOriginalInCookie($inputFilterOriginal) { $storedInCookie = $this->getFilterOriginalFromCookie(); if (isset($inputFilterOriginal) AND ($inputFilterOriginal != $storedInCookie)) { $config = Zend_Registry::get('config'); $cookieName = $config->settings->session->filter_browse_original; $remember_me_seconds = $config->settings->session->remember_me->cookie_lifetime; $cookieExpire = time() + $remember_me_seconds; setcookie($cookieName, $inputFilterOriginal, $cookieExpire, '/'); } } private function getFilterOriginalFromCookie() { $config = Zend_Registry::get('config'); $cookieName = $config->settings->session->filter_browse_original; $storedInCookie = isset($_COOKIE[$cookieName]) ? $_COOKIE[$cookieName] : NULL; return $storedInCookie; } + + + private function storeFilterTagInCookie($group, $tag) + { + $storedInCookie = $this->getFilterTagFromCookie($group); + + if (isset($tag) AND ($tag != $storedInCookie)) { + $config = Zend_Registry::get('config'); + $cookieName = $config->settings->session->filter_browse_original.$group; + $remember_me_seconds = $config->settings->session->remember_me->cookie_lifetime; + $cookieExpire = time() + $remember_me_seconds; + setcookie($cookieName, $tag, $cookieExpire, '/'); + } + } + + private function getFilterTagFromCookie($group) + { + $config = Zend_Registry::get('config'); + $cookieName = $config->settings->session->filter_browse_original.$group; + + $storedInCookie = isset($_COOKIE[$cookieName]) ? $_COOKIE[$cookieName] : NULL; + + return $storedInCookie; + } + + + public function savetaggroupfilterAction() + { + // Filter-Parameter + $tagGroupId = (int)$this->getParam('group_id', null); + $tagId = (int)$this->getParam('tag_id', null); + + $this->storeFilterTagInCookie($tagGroupId, $tagId); + + $response = array(); + $response['Result'] = 'OK'; + $this->_helper->json($response); + } } \ No newline at end of file diff --git a/application/modules/default/models/ConfigStoreTagGroups.php b/application/modules/default/models/ConfigStoreTagGroups.php new file mode 100644 index 000000000..9ad038043 --- /dev/null +++ b/application/modules/default/models/ConfigStoreTagGroups.php @@ -0,0 +1,49 @@ +. + * + * Created: 23.01.2019 + */ +class Default_Model_ConfigStoreTagGroups +{ + + /** + * @param int $store_id + * @param bool $onlyActive + * + * @return null|array + */ + public function getTagGroupsAsIdForStore($store_id, $onlyActive = true) + { + $modelConfigStoreTagGroups = new Default_Model_DbTable_ConfigStoreTagGroups(); + + $sql = "SELECT `tag_group_id` FROM `config_store_tag_group` WHERE `store_id` = :store_id AND `is_active` = :active ORDER BY `tag_group_id`;"; + + $result = $modelConfigStoreTagGroups->getAdapter()->fetchAll($sql, array('store_id' => $store_id, 'active' => ($onlyActive ? 1 : 0)), Zend_Db::FETCH_COLUMN); + + if (0 == count($result)) { + return null; + } + + return $result; + } + +} \ No newline at end of file diff --git a/application/modules/default/models/DbTable/ConfigStoreTagGroups.php b/application/modules/default/models/DbTable/ConfigStoreTagGroups.php new file mode 100644 index 000000000..df74735f9 --- /dev/null +++ b/application/modules/default/models/DbTable/ConfigStoreTagGroups.php @@ -0,0 +1,50 @@ +. + **/ +class Default_Model_DbTable_ConfigStoreTagGroups extends Local_Model_Table +{ + + protected $_name = "config_store_tag_group"; + + protected $_keyColumnsForRow = array('config_store_taggroup_id'); + + protected $_key = 'config_store_taggroup_id'; + + public function delete($where) + { + $where = parent::_whereExpr($where); + + /** + * Build the DELETE statement + */ + $sql = "UPDATE " . parent::getAdapter()->quoteIdentifier($this->_name, true) . " SET `is_active` = 0, `deleted_at` = NOW() " . (($where) ? " WHERE $where" : ''); + + /** + * Execute the statement and return the number of affected rows + */ + $stmt = parent::getAdapter()->query($sql); + $result = $stmt->rowCount(); + + return $result; + } + +} \ No newline at end of file diff --git a/application/modules/default/models/TagGroup.php b/application/modules/default/models/TagGroup.php index 9ce826d8c..80960424a 100644 --- a/application/modules/default/models/TagGroup.php +++ b/application/modules/default/models/TagGroup.php @@ -1,223 +1,240 @@ . * * Created: 13.09.2017 */ class Default_Model_TagGroup { /** * @inheritDoc */ public function __construct() { } public function fetchGroupHierarchy() { $sql = " SELECT tag_group.group_name, tag.tag_id, tag.tag_name FROM tag_group_item JOIN tag_group ON tag_group.group_id = tag_group_item.tag_group_id JOIN tag ON tag.tag_id = tag_group_item.tag_id "; $resultSet = $this->getAdapter()->fetchAll($sql); $optgroup = array(); foreach ($resultSet as $item) { $optgroup[$item['group_name']][$item['tag_id']] = $item['tag_name']; } return $optgroup; } public function fetchAllGroups() { $sql = " SELECT tag_group.group_name, tag_group.group_id FROM tag_group "; $resultSet = $this->getAdapter()->fetchAll($sql); return $resultSet; } /** * @return Zend_Db_Adapter_Abstract */ private function getAdapter() { return Zend_Db_Table::getDefaultAdapter(); } /** * @param int $group_id * * @return array */ public function fetchGroupItems($group_id) { $sql = "SELECT tag_group_item.tag_group_item_id , tag_group_item.tag_group_id , tag.tag_id, tag.tag_name , tag.tag_fullname , tag.tag_description , tag.is_active FROM tag_group_item JOIN tag ON tag.tag_id = tag_group_item.tag_id WHERE tag_group_id = :group_id"; $resultSet = $this->getAdapter()->fetchAll($sql, array('group_id' => $group_id)); return $resultSet; } /** * @param int $group_id * @param string $tag_name * * @return array */ public function assignGroupTag($group_id, $tag_name,$tag_fullname, $tag_description,$is_active=1) { $tag_id = $this->saveTag($tag_name,$tag_fullname, $tag_description,$is_active); $group_tag_id = $this->saveGroupTag($group_id, $tag_id); $resultSet = $this->fetchOneGroupItem($group_tag_id); return $resultSet; } /** * @param string $tag_name * * @return int */ public function saveTag($tag_name,$tag_fullname, $tag_description,$is_active=1) { $tag_name = strtolower($tag_name); $sql = "SELECT tag_id FROM tag WHERE tag_name = :tagName"; $resultSet = $this->getAdapter()->fetchRow($sql, array('tagName' => $tag_name)); if (empty($resultSet)) { $this->getAdapter()->insert('tag', array('tag_name' => $tag_name, 'tag_fullname' => $tag_fullname, 'tag_description' => $tag_description,'is_active' => $is_active)); $resultId = $this->getAdapter()->lastInsertId(); } else { $resultId = $resultSet['tag_id']; } return $resultId; } /** * @param int $group_id * @param int $tag_id * * @return int */ public function saveGroupTag($group_id, $tag_id) { $sql = "SELECT tag_group_item_id FROM tag_group_item WHERE tag_group_id = :group_id AND tag_id = :tag_id"; $resultSet = $this->getAdapter()->fetchRow($sql, array('group_id' => $group_id, 'tag_id' => $tag_id)); if (empty($resultSet)) { $this->getAdapter()->insert('tag_group_item', array('tag_group_id' => $group_id, 'tag_id' => $tag_id)); $resultId = $this->getAdapter()->lastInsertId(); } else { $resultId = $resultSet['tag_group_item_id']; } return $resultId; } /** * @param int $group_item_id * * @return array|false */ public function fetchOneGroupItem($group_item_id) { $sql = "SELECT tag_group_item.tag_group_item_id , tag_group_item.tag_group_id , tag.tag_id, tag.tag_name , tag.tag_fullname , tag.tag_description , tag.is_active FROM tag_group_item JOIN tag ON tag.tag_id = tag_group_item.tag_id WHERE tag_group_item_id = :group_item_id"; $resultSet = $this->getAdapter()->fetchRow($sql, array('group_item_id' => $group_item_id)); return $resultSet; } public function updateGroupTag($tag_id, $tag_name,$tag_fullname, $tag_description,$is_active=1) { $updateValues = array( 'tag_name' =>$tag_name, 'tag_fullname' => $tag_fullname, 'tag_description' => $tag_description, 'is_active' => $is_active ); $this->getAdapter()->update('tag', $updateValues, array('tag_id = ?' => $tag_id)); } public function deleteGroupTag($groupItemId) { $this->getAdapter()->delete('tag_group_item', array('tag_group_item_id = ?' => $groupItemId)); } public function fetchTagGroupsForCategory($cat_id) { $sql = " SELECT category_tag_group.tag_group_id , tag_group.group_name , tag_group.group_display_name , tag_group.group_legacy_name , category_tag_group.category_id , project_category.title FROM category_tag_group JOIN tag_group ON tag_group.group_id = category_tag_group.tag_group_id JOIN project_category ON project_category.project_category_id = category_tag_group.category_id WHERE category_tag_group.category_id = :cat_id"; $resultSet = $this->getAdapter()->fetchAll($sql, array('cat_id' => $cat_id)); return $resultSet; } public function updateTagGroupsPerCategory($cat_id,$taggroups) { $sql = "delete from category_tag_group where category_id=:cat_id"; $this->getAdapter()->query($sql, array('cat_id' => $cat_id)); if($taggroups){ $taggroup_id =explode(',', $taggroups); $prepared_insert = array_map(function ($id) use ($cat_id) { return "({$cat_id},{$id})"; }, $taggroup_id); $sql = "INSERT IGNORE INTO category_tag_group (category_id, tag_group_id) VALUES " . implode(',', $prepared_insert); $this->getAdapter()->query($sql); } } + + public function updateTagGroupsPerStore($store_id,$taggroups) + { + $sql = "delete from config_store_tag_group where store_id=:store_id"; + $this->getAdapter()->query($sql, array('store_id' => $store_id)); + + if($taggroups){ + $taggroup_id =explode(',', $taggroups); + $prepared_insert = + array_map(function ($id) use ($store_id) { return "({$store_id},{$id})"; }, + $taggroup_id); + $sql = "INSERT IGNORE INTO config_store_tag_group (store_id, tag_group_id) VALUES " . implode(',', + $prepared_insert); + + $this->getAdapter()->query($sql); + } + } } \ No newline at end of file diff --git a/application/modules/default/models/Tags.php b/application/modules/default/models/Tags.php index 279d5b15d..cba8c6a20 100644 --- a/application/modules/default/models/Tags.php +++ b/application/modules/default/models/Tags.php @@ -1,1026 +1,1041 @@ . * * Created: 11.09.2017 */ class Default_Model_Tags { const TAG_TYPE_PROJECT = 1; const TAG_TYPE_MEMBER = 2; const TAG_TYPE_FILE = 3; const TAG_USER_GROUPID = 5; const TAG_CATEGORY_GROUPID = 6; const TAG_LICENSE_GROUPID = 7; const TAG_PACKAGETYPE_GROUPID = 8; const TAG_ARCHITECTURE_GROUPID = 9; const TAG_GHNS_EXCLUDED_GROUPID = 10; const TAG_PRODUCT_ORIGINAL_GROUPID = 11; const TAG_PRODUCT_ORIGINAL_ID = 2451; const TAG_PRODUCT_EBOOK_GROUPID = 14; const TAG_PRODUCT_EBOOK_AUTHOR_GROUPID = 15; const TAG_PRODUCT_EBOOK_EDITOR_GROUPID = 16; const TAG_PRODUCT_EBOOK_ILLUSTRATOR_GROUPID = 17; const TAG_PRODUCT_EBOOK_TRANSLATOR_GROUPID = 18; const TAG_PRODUCT_EBOOK_SUBJECT_GROUPID = 19; const TAG_PRODUCT_EBOOK_SHELF_GROUPID = 20; const TAG_PRODUCT_EBOOK_LANGUAGE_GROUPID = 21; const TAG_PRODUCT_EBOOK_TYPE_GROUPID = 22; const TAG_PRODUCT_EBOOK_ID = 2532; const TAG_PROJECT_GROUP_IDS = '6,7,10';//type product : category-tags, license-tags,ghns_excluded const TAG_FILE_GROUP_IDS = '8,9';//file-packagetype-tags,file-architecture-tags // $tag_project_group_ids ='6,7,10'; // $tag_file_group_ids ='8,9'; /** * Default_Model_Tags constructor. */ public function __construct() { } /** * @param int $object_id * @param string $tags * @param int $tag_type */ public function processTags($object_id, $tags, $tag_type) { $this->assignTags($object_id, $tags, $tag_type); $this->deassignTags($object_id, $tags, $tag_type); } /** * @param int $object_id * @param string $tags * @param int $tag_type */ public function assignTags($object_id, $tags, $tag_type) { $new_tags = array_diff(explode(',', $tags), explode(',', $this->getTags($object_id, $tag_type))); $tableTags = new Default_Model_DbTable_Tags(); $listIds = $tableTags->storeTags(implode(',', $new_tags)); $prepared_insert = array_map(function ($id) use ($object_id, $tag_type) { return "({$id}, {$tag_type}, {$object_id})"; }, $listIds); $sql = "INSERT IGNORE INTO tag_object (tag_id, tag_type_id, tag_object_id) VALUES " . implode(',', $prepared_insert); $this->getAdapter()->query($sql); } /** * @param int $object_id * @param int $tag_type * * @return string|null */ public function getTags($object_id, $tag_type) { $sql = " SELECT GROUP_CONCAT(tag.tag_name) AS tag_names FROM tag_object JOIN tag ON tag.tag_id = tag_object.tag_id join tag_group_item on tag_object.tag_id = tag_group_item.tag_id WHERE tag_type_id = :type AND tag_object_id = :object_id and tag_group_item.tag_group_id <> :tag_user_groupid and tag_object.is_deleted = 0 GROUP BY tag_object.tag_object_id "; $result = $this->getAdapter()->fetchRow($sql, array('type' => $tag_type, 'object_id' => $object_id, 'tag_user_groupid' =>Default_Model_Tags::TAG_USER_GROUPID )); if (isset($result['tag_names'])) { return $result['tag_names']; } return null; } /** * @param int $object_id * @param int $tag_type * @param String $tag_group_ids * * @return string|null */ public function getTagsArray($object_id, $tag_type,$tag_group_ids) { $sql = " SELECT tag.tag_id,tag.tag_name,tag_group_item.tag_group_id,tag.tag_fullname FROM tag_object JOIN tag ON tag.tag_id = tag_object.tag_id join tag_group_item on tag_object.tag_id = tag_group_item.tag_id and tag_object.tag_group_id = tag_group_item.tag_group_id WHERE tag_type_id = :type AND tag_object_id = :object_id and tag_object.tag_group_id in ({$tag_group_ids} ) and tag_object.is_deleted = 0 order by tag_group_item.tag_group_id desc , tag.tag_name asc "; $result = $this->getAdapter()->fetchAll($sql, array('type' => $tag_type, 'object_id' => $object_id)); return $result; } /** * @param int $object_id * @param int $tag_type * * @return string|null */ public function getTagsUser($object_id, $tag_type) { $tag_group_ids =$this::TAG_USER_GROUPID; $tags = $this->getTagsArray($object_id, $tag_type,$tag_group_ids); $tag_names = ''; foreach ($tags as $tag) { $tag_names=$tag_names.$tag['tag_name'].','; } $len = strlen($tag_names); if ($len>0) { return substr($tag_names,0,($len-1)); } return null; } /** * @param int $projectid * @param int $tag * * @return string|null */ public function isTagsUserExisting($project_id, $tagname) { $sql_object= "select count(1) as cnt from tag_object JOIN tag ON tag.tag_id = tag_object.tag_id WHERE tag.tag_name = :tagname and tag_object.tag_group_id=:tag_group_id and tag_object.is_deleted=0 and tag_object.tag_object_id=:project_id and tag_object.tag_type_id=:tag_type_id"; $r = $this->getAdapter()->fetchRow($sql_object, array( 'tagname' => $tagname ,'tag_group_id'=>Default_Model_Tags::TAG_USER_GROUPID , 'project_id'=>$project_id , 'tag_type_id'=>Default_Model_Tags::TAG_TYPE_PROJECT )); if($r['cnt'] ==0){ return false; }else{ return true; } } /** * @param int $object_id * @param int $tag_type * * @return string|null */ public function getTagsCategory($object_id, $tag_type) { $tag_group_ids = $this::TAG_CATEGORY_GROUPID; $tags = $this->getTagsArray($object_id, $tag_type,$tag_group_ids); $tag_names = ''; foreach ($tags as $tag) { $tag_names=$tag_names.$tag['tag_name'].','; } $len = strlen($tag_names); if ($len>0) { return substr($tag_names,0,($len-1)); } return null; } /** * @param int $object_id * @param int $tag_type * * @return string|null */ public function getTagsSystem($object_id, $tag_type) { $tag_group_ids ='6,7,10'; $tags = $this->getTagsArray($object_id, $tag_type,$tag_group_ids); $tag_names = ''; foreach ($tags as $tag) { $tag_names=$tag_names.$tag['tag_name'].','; } $len = strlen($tag_names); if ($len>0) { return substr($tag_names,0,($len-1)); } return null; } /** * @param int $object_id * @param int $tag_type * * @return string|null */ public function getTagsSystemList($project_id) { $tag_project_group_ids = SELF::TAG_PROJECT_GROUP_IDS; $tag_file_group_ids = SELF::TAG_FILE_GROUP_IDS; $sql =" SELECT tag.tag_id,tag.tag_name,tag_object.tag_group_id FROM tag_object JOIN tag ON tag.tag_id = tag_object.tag_id WHERE tag_type_id = :type_project AND tag_object_id = :project_id and tag_object.tag_group_id in ({$tag_project_group_ids} ) and tag_object.is_deleted = 0 union all SELECT distinct t.tag_id,t.tag_name,o.tag_group_id FROM tag_object o JOIN tag t ON t.tag_id = o.tag_id inner join project p on o.tag_parent_object_id = p.project_id inner join ppload.ppload_files f on p.ppload_collection_id = f.collection_id and o.tag_object_id=f.id and f.active = 1 WHERE o.tag_type_id = :type_file AND p.project_id = :project_id and o.tag_group_id in ({$tag_file_group_ids} ) and o.is_deleted = 0 order by tag_group_id , tag_name "; $result = $this->getAdapter()->fetchAll($sql, array('type_project' => Default_Model_Tags::TAG_TYPE_PROJECT , 'project_id' => $project_id , 'type_file' => Default_Model_Tags::TAG_TYPE_FILE )); return $result; } /** * @param int $object_id * @param int $tag_type * * @return string|null */ public function getTagsUserCount($object_id, $tag_type) { $sql = " SELECT count(*) as cnt FROM tag_object JOIN tag ON tag.tag_id = tag_object.tag_id join tag_group_item on tag_object.tag_id = tag_group_item.tag_id and tag_object.tag_group_id = tag_group_item.tag_group_id WHERE tag_type_id = :type AND tag_object_id = :object_id and tag_object.is_deleted = 0 and tag_group_item.tag_group_id = :tag_user_groupid "; $result = $this->getAdapter()->fetchRow($sql, array('type' => $tag_type, 'object_id' => $object_id, 'tag_user_groupid' =>Default_Model_Tags::TAG_USER_GROUPID )); if (isset($result['cnt'])) { return $result['cnt']; } return 0; } public function filterTagsUser($filter, $limit) { $sql = " select tag.tag_id ,tag.tag_name from tag join tag_group_item on tag.tag_id = tag_group_item.tag_id and tag_group_item.tag_group_id = :tag_user_groupid where tag.tag_name like '%".$filter."%' "; if (isset($limit)) { $sql.= ' limit ' . $limit; } $result = $this->getAdapter()->fetchAll($sql, array('tag_user_groupid' =>Default_Model_Tags::TAG_USER_GROUPID )); return $result; } /** * @return Zend_Db_Adapter_Abstract */ private function getAdapter() { return Zend_Db_Table::getDefaultAdapter(); } /** * @param int $object_id * @param string $tags * @param int $tag_type */ public function deassignTags($object_id, $tags, $tag_type) { $removable_tags = array_diff(explode(',', $this->getTags($object_id, $tag_type)), explode(',', $tags)); //$sql = "DELETE tag_object FROM tag_object JOIN tag ON tag.tag_id = tag_object.tag_id WHERE tag.tag_name = :name and tag_object.tag_object_id=:object_id"; $sql = "UPDATE tag_object inner join tag ON tag.tag_id = tag_object.tag_id SET tag_changed = NOW() , is_deleted = 1 WHERE tag.tag_name = :name and tag_object.tag_object_id=:object_id"; $this->getAdapter()->query($sql, array('tagObjectId' => $object_id, 'tagType' => $tag_type)); foreach ($removable_tags as $removable_tag) { $this->getAdapter()->query($sql, array('name' => $removable_tag,'object_id' => $object_id)); } $this->updateChanged($object_id, $tag_type); } /** * @param int $object_id * @param string $tags * @param int $tag_type */ public function processTagsUser($object_id, $tags, $tag_type) { if($tags) { $this->assignTagsUser($object_id, $tags, $tag_type); } $this->deassignTagsUser($object_id, $tags, $tag_type); } public function isProuductOriginal($project_id) { $sql_object= "select tag_item_id from tag_object WHERE tag_id = :tag_id and tag_object_id=:tag_object_id and tag_group_id=:tag_group_id and tag_type_id = :tag_type_id and is_deleted = 0"; $r = $this->getAdapter()->fetchRow($sql_object, array('tag_id' => self::TAG_PRODUCT_ORIGINAL_ID, 'tag_object_id' =>$project_id, 'tag_group_id' => self::TAG_PRODUCT_ORIGINAL_GROUPID, 'tag_type_id' => self::TAG_TYPE_PROJECT )); if($r){ return true; }else { return false; } } public function isProuductEbook($project_id) { $sql_object= "select tag_item_id from tag_object WHERE tag_id = :tag_id and tag_object_id=:tag_object_id and tag_group_id=:tag_group_id and tag_type_id = :tag_type_id and is_deleted = 0"; $r = $this->getAdapter()->fetchRow($sql_object, array('tag_id' => self::TAG_PRODUCT_EBOOK_ID, 'tag_object_id' =>$project_id, 'tag_group_id' => self::TAG_PRODUCT_EBOOK_GROUPID, 'tag_type_id' => self::TAG_TYPE_PROJECT )); if($r){ return true; }else { return false; } } /** * @param int $object_id * @param string $value */ public function processTagProductOriginal($object_id, $is_original) { $sql_object= "select tag_item_id from tag_object WHERE tag_id = :tag_id and tag_object_id=:tag_object_id and tag_group_id=:tag_group_id and tag_type_id = :tag_type_id and is_deleted = 0"; $r = $this->getAdapter()->fetchRow($sql_object, array('tag_id' => self::TAG_PRODUCT_ORIGINAL_ID, 'tag_object_id' =>$object_id, 'tag_group_id' => self::TAG_PRODUCT_ORIGINAL_GROUPID, 'tag_type_id' => self::TAG_TYPE_PROJECT )); if($is_original=='1') { if(!$r){ $sql = "INSERT IGNORE INTO tag_object (tag_id, tag_type_id, tag_object_id, tag_group_id) VALUES (:tag_id, :tag_type_id, :tag_object_id, :tag_group_id)"; $this->getAdapter()->query($sql, array('tag_id' => self::TAG_PRODUCT_ORIGINAL_ID, 'tag_type_id' => self::TAG_TYPE_PROJECT , 'tag_object_id' => $object_id, 'tag_group_id' => self::TAG_PRODUCT_ORIGINAL_GROUPID)); } }else{ if($r){ $sql = "UPDATE tag_object set tag_changed = NOW() , is_deleted = 1 WHERE tag_item_id = :tagItemId"; $this->getAdapter()->query($sql, array('tagItemId' => $r['tag_item_id'])); } } } /** * @param int $object_id * @param string $tags * @param int $tag_type */ public function assignTagsUser($object_id, $tags, $tag_type) { $tags = strtolower($tags); $tag_group_id = 5; $new_tags = array_diff(explode(',', $tags), explode(',', $this->getTagsUser($object_id, $tag_type))); if(sizeof($new_tags)>0) { $tableTags = new Default_Model_DbTable_Tags(); $listIds = $tableTags->storeTagsUser(implode(',', $new_tags)); $prepared_insert = array_map(function ($id) use ($object_id, $tag_type,$tag_group_id) { return "({$id}, {$tag_type}, {$object_id},{$tag_group_id})"; }, $listIds); $sql = "INSERT IGNORE INTO tag_object (tag_id, tag_type_id, tag_object_id,tag_group_id) VALUES " . implode(',', $prepared_insert); $this->getAdapter()->query($sql); } } /** * @param int $object_id * @param string $tags * @param int $tag_type */ public function addTagUser($object_id, $tag, $tag_type) { $tableTags = new Default_Model_DbTable_Tags(); $listIds = $tableTags->storeTagsUser($tag); $tag_group_id = $this::TAG_USER_GROUPID; $prepared_insert = array_map(function ($id) use ($object_id, $tag_type,$tag_group_id) { return "({$id}, {$tag_type}, {$object_id},{$tag_group_id})"; }, $listIds); $sql = "INSERT IGNORE INTO tag_object (tag_id, tag_type_id, tag_object_id,tag_group_id) VALUES " . implode(',', $prepared_insert); $this->getAdapter()->query($sql); } public function deassignTagsUser($object_id, $tags, $tag_type) { if($tags) { $tags = strtolower($tags); $removable_tags = array_diff(explode(',', $this->getTagsUser($object_id, $tag_type)), explode(',', $tags)); } else { $removable_tags = explode(',', $this->getTagsUser($object_id, $tag_type)); } //$sql = "DELETE tag_object FROM tag_object JOIN tag ON tag.tag_id = tag_object.tag_id WHERE tag_group_id = ".Default_Model_Tags::TAG_USER_GROUPID." and tag.tag_name = :name and tag_object.tag_object_id=:object_id"; $sql = "UPDATE tag_object inner join tag ON tag.tag_id = tag_object.tag_id set tag_changed = NOW() , is_deleted = 1 WHERE tag_group_id = ".Default_Model_Tags::TAG_USER_GROUPID." and tag.tag_name = :name and tag_object.tag_object_id=:object_id"; foreach ($removable_tags as $removable_tag) { $this->getAdapter()->query($sql, array('name' => $removable_tag,'object_id' => $object_id)); // if Tag is the only one in Tag_object table then delete this tag for user_groupid = 5 $sql_object= "select count(1) as cnt from tag_object JOIN tag ON tag.tag_id = tag_object.tag_id WHERE tag.tag_name = :name"; $r = $this->getAdapter()->fetchRow($sql_object, array('name' => $removable_tag)); if($r['cnt'] ==0){ // then remove tag if not existing in Tag_object $sql_delete_tag = "delete from tag where tag_name=:name"; $this->getAdapter()->query($sql_delete_tag, array('name' => $removable_tag)); } } $this->updateChanged($object_id, $tag_type); } public function deleteTagUser($object_id, $tag, $tag_type) { $removable_tag =$tag; // $sql = "DELETE tag_object FROM tag_object JOIN tag ON tag.tag_id = tag_object.tag_id WHERE tag_group_id = ".Default_Model_Tags::TAG_USER_GROUPID." and tag.tag_name = :name and tag_object.tag_object_id=:object_id // and tag_group_id =".Default_Model_Tags::TAG_USER_GROUPID; $sql = "UPDATE tag_object inner join tag ON tag.tag_id = tag_object.tag_id set tag_changed = NOW() , is_deleted = 1 WHERE tag_group_id = ".Default_Model_Tags::TAG_USER_GROUPID." and tag.tag_name = :name and tag_object.tag_object_id=:object_id"; $this->getAdapter()->query($sql, array('name' => $removable_tag,'object_id' => $object_id)); // if Tag is the only one in Tag_object table then delete this tag for user_groupid = 5 $sql_object= "select count(1) as cnt from tag_object JOIN tag ON tag.tag_id = tag_object.tag_id WHERE tag.tag_name = :name "; $r = $this->getAdapter()->fetchRow($sql_object, array('name' => $removable_tag)); if($r['cnt'] ==0){ // then remove tag if not existing in Tag_object $sql_delete_tag = "delete from tag where tag_name=:name"; $this->getAdapter()->query($sql_delete_tag, array('name' => $removable_tag)); } $this->updateChanged($object_id, $tag_type); } private function updateChanged($object_id, $tag_type) { $sql = "UPDATE tag_object SET tag_changed = NOW() WHERE tag_object_id = :tagObjectId AND tag_type_id = :tagType"; $this->getAdapter()->query($sql, array('tagObjectId' => $object_id, 'tagType' => $tag_type)); } public function getTagsPerCategory($cat_id) { $sql = "select t.* from category_tag as c ,tag as t where c.tag_id = t.tag_id and c.category_id = :cat_id"; $r = $this->getAdapter()->fetchAll($sql, array('cat_id' => $cat_id)); return $r; } public function updateTagsPerCategory($cat_id,$tags) { $sql = "delete from category_tag where category_id=:cat_id"; $this->getAdapter()->query($sql, array('cat_id' => $cat_id)); if($tags){ $tags_id =explode(',', $tags); $prepared_insert = array_map(function ($id) use ($cat_id) { return "({$cat_id},{$id})"; }, $tags_id); $sql = "INSERT IGNORE INTO category_tag (category_id, tag_id) VALUES " . implode(',', $prepared_insert); $this->getAdapter()->query($sql); } } public function updateTagsPerStore($store_id,$tags) { $sql = "delete from config_store_tag where store_id=:store_id"; $this->getAdapter()->query($sql, array('store_id' => $store_id)); if($tags){ $tags_id =explode(',', $tags); $prepared_insert = array_map(function ($id) use ($store_id) { return "({$store_id},{$id})"; }, $tags_id); $sql = "INSERT IGNORE INTO config_store_tag (store_id, tag_id) VALUES " . implode(',', $prepared_insert); $this->getAdapter()->query($sql); } } public function getTagsPerGroup($groupid) { $sql = " select tag.tag_id ,tag.tag_name from tag join tag_group_item on tag.tag_id = tag_group_item.tag_id and tag_group_item.tag_group_id = :groupid order by tag_name "; $result = $this->getAdapter()->fetchAll($sql, array('groupid' => $groupid)); return $result; } public function getAllTagsForStoreFilter() { $sql = " select tag.tag_id, CASE WHEN tag.tag_fullname IS NULL THEN tag_name ELSE tag.tag_fullname END as tag_name from tag where tag.is_active = 1 order by tag_name "; $result = $this->getAdapter()->fetchAll($sql); return $result; } + + + public function getAllTagGroupsForStoreFilter() + { + $sql = " + select + tag_group.group_id, + tag_group.group_name as group_name + from tag_group + order by tag_group.group_name + + "; + $result = $this->getAdapter()->fetchAll($sql); + return $result; + } public function saveLicenseTagForProject($object_id, $tag_id) { $tableTags = new Default_Model_DbTable_Tags(); $tags = $tableTags->fetchLicenseTagsForProject($object_id); if(count($tags) ==0){ //insert new tag if($tag_id) { $sql = "INSERT IGNORE INTO tag_object (tag_id, tag_type_id, tag_object_id, tag_group_id) VALUES (:tag_id, :tag_type_id, :tag_object_id, :tag_group_id)"; $this->getAdapter()->query($sql, array('tag_id' => $tag_id, 'tag_type_id' => $this::TAG_TYPE_PROJECT, 'tag_object_id' => $object_id, 'tag_group_id' => $this::TAG_LICENSE_GROUPID)); } }else { $tag = $tags[0]; //remove tag license if(!$tag_id) { //$sql = "DELETE FROM tag_object WHERE tag_item_id = :tagItemId"; $sql = "UPDATE tag_object set tag_changed = NOW() , is_deleted = 1 WHERE tag_item_id = :tagItemId"; $this->getAdapter()->query($sql, array('tagItemId' => $tag['tag_item_id'])); } else { //Update old tag if($tag_id <> $tag['tag_id']) { $sql = "UPDATE tag_object SET tag_changed = NOW(),tag_id = :tag_id WHERE tag_item_id = :tagItemId"; $this->getAdapter()->query($sql, array('tagItemId' => $tag['tag_item_id'], 'tag_id' => $tag_id)); } } } // if(count($tags) >= 1) { // $tag = $tags[0]; // //remove tag license // if(!$tag_id) { // //$sql = "DELETE FROM tag_object WHERE tag_item_id = :tagItemId"; // $sql = "UPDATE tag_object set tag_changed = NOW() , is_deleted = 1 WHERE tag_item_id = :tagItemId"; // $this->getAdapter()->query($sql, array('tagItemId' => $tag['tag_item_id'])); // } else { // //Update old tag // if($tag_id <> $tag['tag_id']) { // $sql = "UPDATE tag_object SET tag_changed = NOW(),tag_id = :tag_id WHERE tag_item_id = :tagItemId"; // $this->getAdapter()->query($sql, array('tagItemId' => $tag['tag_item_id'], 'tag_id' => $tag_id)); // } // } // } else { // //insert new tag // if($tag_id) { // $sql = "INSERT IGNORE INTO tag_object (tag_id, tag_type_id, tag_object_id, tag_group_id) VALUES (:tag_id, :tag_type_id, :tag_object_id, :tag_group_id)"; // $this->getAdapter()->query($sql, array('tag_id' => $tag_id, 'tag_type_id' => $this::TAG_TYPE_PROJECT, 'tag_object_id' => $object_id, 'tag_group_id' => $this::TAG_LICENSE_GROUPID)); // } // } } public function saveGhnsExcludedTagForProject($object_id, $tag_value) { $tableTags = new Default_Model_DbTable_Tags(); $ghnsExcludedTagId = $tableTags->fetchGhnsExcludedTagId(); $sql = "UPDATE tag_object SET tag_changed = NOW() , is_deleted = 1 WHERE tag_group_id = :tag_group_id AND tag_type_id = :tag_type_id AND tag_object_id = :tag_object_id"; $this->getAdapter()->query($sql, array('tag_group_id' => $this::TAG_GHNS_EXCLUDED_GROUPID, 'tag_type_id' => $this::TAG_TYPE_PROJECT, 'tag_object_id' => $object_id)); if($tag_value == 1) { $sql = "INSERT IGNORE INTO tag_object (tag_id, tag_type_id, tag_object_id, tag_group_id) VALUES (:tag_id, :tag_type_id, :tag_object_id, :tag_group_id)"; $this->getAdapter()->query($sql, array('tag_id' => $ghnsExcludedTagId, 'tag_type_id' => $this::TAG_TYPE_PROJECT, 'tag_object_id' => $object_id, 'tag_group_id' => $this::TAG_GHNS_EXCLUDED_GROUPID)); } } public function saveArchitectureTagForProject($project_id, $file_id, $tag_id) { //first delte old //$sql = "DELETE FROM tag_object WHERE tag_group_id = :tag_group_id AND tag_type_id = :tag_type_id AND tag_object_id = :tag_object_id AND tag_parent_object_id = :tag_parent_object_id"; $sql = "UPDATE tag_object SET tag_changed = NOW() , is_deleted = 1 WHERE tag_group_id = :tag_group_id AND tag_type_id = :tag_type_id AND tag_object_id = :tag_object_id AND tag_parent_object_id = :tag_parent_object_id"; $this->getAdapter()->query($sql, array('tag_group_id' => $this::TAG_ARCHITECTURE_GROUPID, 'tag_type_id' => $this::TAG_TYPE_FILE, 'tag_object_id' => $file_id, 'tag_parent_object_id' => $project_id)); if($tag_id) { $sql = "INSERT IGNORE INTO tag_object (tag_id, tag_type_id, tag_object_id, tag_parent_object_id, tag_group_id) VALUES (:tag_id, :tag_type_id, :tag_object_id, :tag_parent_object_id, :tag_group_id)"; $this->getAdapter()->query($sql, array('tag_id' => $tag_id, 'tag_type_id' => $this::TAG_TYPE_FILE, 'tag_object_id' => $file_id, 'tag_parent_object_id' => $project_id, 'tag_group_id' => $this::TAG_ARCHITECTURE_GROUPID)); } /** $tableTags = new Default_Model_DbTable_Tags(); $tags = $tableTags->fetchArchitectureTagsForProject($object_id); if(count($tags) == 1) { $tag = $tags[0]; //remove tag license if(!$tag_id) { $sql = "DELETE FROM tag_object WHERE tag_item_id = :tagItemId"; $this->getAdapter()->query($sql, array('tagItemId' => $tag['tag_item_id'])); } else { //Update old tag if($tag_id <> $tag['tag_id']) { $sql = "UPDATE tag_object SET tag_changed = NOW(),tag_id = :tag_id WHERE tag_item_id = :tagItemId"; $this->getAdapter()->query($sql, array('tagItemId' => $tag['tag_item_id'], 'tag_id' => $tag_id)); } } } else { //insert new tag if($tag_id) { $sql = "INSERT IGNORE INTO tag_object (tag_id, tag_type_id, tag_object_id, tag_group_id) VALUES (:tag_id, :tag_type_id, :tag_object_id, :tag_group_id)"; $this->getAdapter()->query($sql, array('tag_id' => $tag_id, 'tag_type_id' => $this::TAG_TYPE_PROJECT, 'tag_object_id' => $object_id, 'tag_group_id' => $this::TAG_ARCHITECTURE_GROUPID)); } } * */ } public function saveFileTagForProjectAndTagGroup($project_id, $file_id, $tag_id, $tag_group_id) { //first delte old $sql = "UPDATE tag_object SET tag_changed = NOW() , is_deleted = 1 WHERE tag_group_id = :tag_group_id AND tag_type_id = :tag_type_id AND tag_object_id = :tag_object_id AND tag_parent_object_id = :tag_parent_object_id"; $this->getAdapter()->query($sql, array('tag_group_id' => $tag_group_id, 'tag_type_id' => $this::TAG_TYPE_FILE, 'tag_object_id' => $file_id, 'tag_parent_object_id' => $project_id)); if($tag_id) { $sql = "INSERT IGNORE INTO tag_object (tag_id, tag_type_id, tag_object_id, tag_parent_object_id, tag_group_id) VALUES (:tag_id, :tag_type_id, :tag_object_id, :tag_parent_object_id, :tag_group_id)"; $this->getAdapter()->query($sql, array('tag_id' => $tag_id, 'tag_type_id' => $this::TAG_TYPE_FILE, 'tag_object_id' => $file_id, 'tag_parent_object_id' => $project_id, 'tag_group_id' => $tag_group_id)); } } public function deleteFileTagForProject($project_id, $file_id, $tag_id) { //first delte old $sql = "UPDATE tag_object SET tag_changed = NOW() , is_deleted = 1 WHERE tag_id= :tag_id AND tag_type_id = :tag_type_id AND tag_object_id = :tag_object_id AND tag_parent_object_id = :tag_parent_object_id"; $this->getAdapter()->query($sql, array('tag_id' => $tag_id, 'tag_type_id' => $this::TAG_TYPE_FILE, 'tag_object_id' => $file_id, 'tag_parent_object_id' => $project_id)); } public function savePackagetypeTagForProject($project_id, $file_id, $tag_id) { //first delte old $sql = "UPDATE tag_object SET tag_changed = NOW() , is_deleted = 1 WHERE tag_group_id = :tag_group_id AND tag_type_id = :tag_type_id AND tag_object_id = :tag_object_id AND tag_parent_object_id = :tag_parent_object_id"; $this->getAdapter()->query($sql, array('tag_group_id' => $this::TAG_PACKAGETYPE_GROUPID, 'tag_type_id' => $this::TAG_TYPE_FILE, 'tag_object_id' => $file_id, 'tag_parent_object_id' => $project_id)); if($tag_id) { $sql = "INSERT IGNORE INTO tag_object (tag_id, tag_type_id, tag_object_id, tag_parent_object_id, tag_group_id) VALUES (:tag_id, :tag_type_id, :tag_object_id, :tag_parent_object_id, :tag_group_id)"; $this->getAdapter()->query($sql, array('tag_id' => $tag_id, 'tag_type_id' => $this::TAG_TYPE_FILE, 'tag_object_id' => $file_id, 'tag_parent_object_id' => $project_id, 'tag_group_id' => $this::TAG_PACKAGETYPE_GROUPID)); } } public function getProjectPackageTypesString($projectId) { $sql = 'SELECT DISTINCT ta.tag_fullname as name FROM tag_object t INNER JOIN tag ta on ta.tag_id = t.tag_id WHERE t.tag_group_id = :tag_group_id AND t.tag_parent_object_id = :project_id AND t.is_deleted = 0'; $resultSet = $this->getAdapter()->fetchAll($sql, array('tag_group_id' => $this::TAG_PACKAGETYPE_GROUPID,'project_id' => $projectId)); $resultString = ''; if (count($resultSet) > 0) { foreach ($resultSet as $item) { $resultString = $resultString . ' ' . stripslashes($item['name']) . ''; } return $resultString; } return ''; } public function getProjectPackageTypesPureStrings($projectId) { $sql = 'SELECT DISTINCT ta.tag_fullname as name FROM tag_object t INNER JOIN tag ta on ta.tag_id = t.tag_id WHERE t.tag_group_id = :tag_group_id AND t.tag_parent_object_id = :project_id AND t.is_deleted = 0'; $resultSet = $this->getAdapter()->fetchAll($sql, array('tag_group_id' => $this::TAG_PACKAGETYPE_GROUPID,'project_id' => $projectId)); $resultString = ''; if (count($resultSet) > 0) { foreach ($resultSet as $item) { $resultString = $resultString .' '. stripslashes($item['name']) ; } return $resultString; } return ''; } public function deleteFileTagsOnProject($projectId, $fileId) { $sql = "UPDATE tag_object inner join tag ON tag.tag_id = tag_object.tag_id set tag_changed = NOW() , is_deleted = 1 WHERE tag_type_id = :tag_type_id and tag_object.tag_object_id=:object_id and tag_object.tag_parent_object_id=:parent_object_id"; $this->getAdapter()->query($sql, array('tag_type_id' => $this::TAG_TYPE_FILE, 'object_id' => $fileId, 'parent_object_id' => $projectId)); } public function deletePackageTypeOnProject($projectId, $fileId) { $sql = "UPDATE tag_object inner join tag ON tag.tag_id = tag_object.tag_id set tag_changed = NOW() , is_deleted = 1 WHERE tag_group_id = :tag_group_id and tag_object.tag_object_id=:object_id and tag_object.tag_parent_object_id=:parent_object_id"; $this->getAdapter()->query($sql, array('tag_group_id' => $this::TAG_PACKAGETYPE_GROUPID, 'object_id' => $fileId, 'parent_object_id' => $projectId)); } public function deleteArchitectureOnProject($projectId, $fileId) { $sql = "UPDATE tag_object inner join tag ON tag.tag_id = tag_object.tag_id set tag_changed = NOW() , is_deleted = 1 WHERE tag_group_id = :tag_group_id and tag_object.tag_object_id=:object_id and tag_object.tag_parent_object_id=:parent_object_id"; $this->getAdapter()->query($sql, array('tag_group_id' => $this::TAG_ARCHITECTURE_GROUPID, 'object_id' => $fileId, 'parent_object_id' => $projectId)); } /** * @param int $projectId * @param int $fileId * @return string */ public function getPackageType($projectId, $fileId) { $sql = 'SELECT ta.tag_fullname as name FROM tag_object t INNER JOIN tag ta on ta.tag_id = t.tag_id WHERE t.tag_group_id = :tag_group_id AND t.tag_parent_object_id = :project_id AND t.tag_object_id = :file_id AND t.is_deleted = 0'; $resultSet = $this->getAdapter()->fetchAll($sql, array('tag_group_id' => $this::TAG_PACKAGETYPE_GROUPID,'project_id' => $projectId, 'file_id' => $fileId)); if (count($resultSet) > 0) { return $resultSet[0]['name']; } else { return ''; } } /** * @param int $projectId * @param int $fileId * @return string */ public function getFileTags($fileId) { $sql = 'SELECT ta.tag_id, ta.tag_fullname as name FROM tag_object t INNER JOIN tag ta on ta.tag_id = t.tag_id WHERE t.tag_type_id = :tag_type_id AND t.tag_object_id = :file_id AND t.is_deleted = 0'; $resultSet = $this->getAdapter()->fetchAll($sql, array('tag_type_id' => $this::TAG_TYPE_FILE,'file_id' => $fileId)); return $resultSet; } /** * @param int $projectId * @param int $fileId * @return string */ public function getTagsForFileAndTagGroup($projectId, $fileId, $tagGroup) { $sql = 'SELECT ta.tag_fullname as name FROM tag_object t INNER JOIN tag ta on ta.tag_id = t.tag_id WHERE t.tag_group_id = :tag_group_id AND t.tag_parent_object_id = :project_id AND t.tag_object_id = :file_id AND t.is_deleted = 0'; $resultSet = $this->getAdapter()->fetchAll($sql, array('tag_group_id' => $tagGroup,'project_id' => $projectId, 'file_id' => $fileId)); return $resultSet; } /** * @param int $object_id * * @return string|null */ public function getTagsEbookSubject($object_id) { $tag_group_ids =$this::TAG_PRODUCT_EBOOK_SUBJECT_GROUPID; $tags = $this->getTagsArray($object_id, $this::TAG_TYPE_PROJECT,$tag_group_ids); $tag_names = array(); foreach ($tags as $tag) { $tag_names[]=$tag['tag_fullname']; } return $tag_names; } /** * @param int $object_id * * @return string|null */ public function getTagsEbookAuthor($object_id) { $tag_group_ids =$this::TAG_PRODUCT_EBOOK_AUTHOR_GROUPID; $tags = $this->getTagsArray($object_id, $this::TAG_TYPE_PROJECT,$tag_group_ids); $tag_names = array(); foreach ($tags as $tag) { $tag_names[]=$tag['tag_fullname']; } return $tag_names; } /** * @param int $object_id * * @return string|null */ public function getTagsEbookEditor($object_id) { $tag_group_ids =$this::TAG_PRODUCT_EBOOK_EDITOR_GROUPID; $tags = $this->getTagsArray($object_id, $this::TAG_TYPE_PROJECT,$tag_group_ids); $tag_names = array(); foreach ($tags as $tag) { $tag_names[]=$tag['tag_fullname']; } return $tag_names; } /** * @param int $object_id * * @return string|null */ public function getTagsEbookIllustrator($object_id) { $tag_group_ids =$this::TAG_PRODUCT_EBOOK_ILLUSTRATOR_GROUPID; $tags = $this->getTagsArray($object_id, $this::TAG_TYPE_PROJECT,$tag_group_ids); $tag_names = array(); foreach ($tags as $tag) { $tag_names[]=$tag['tag_fullname']; } return $tag_names; } /** * @param int $object_id * * @return string|null */ public function getTagsEbookTranslator($object_id) { $tag_group_ids =$this::TAG_PRODUCT_EBOOK_TRANSLATOR_GROUPID; $tags = $this->getTagsArray($object_id, $this::TAG_TYPE_PROJECT,$tag_group_ids); $tag_names = array(); foreach ($tags as $tag) { $tag_names[]=$tag['tag_fullname']; } return $tag_names; } /** * @param int $object_id * * @return string|null */ public function getTagsEbookShelf($object_id) { $tag_group_ids =$this::TAG_PRODUCT_EBOOK_SHELF_GROUPID; $tags = $this->getTagsArray($object_id, $this::TAG_TYPE_PROJECT,$tag_group_ids); $tag_names = array(); foreach ($tags as $tag) { $tag_names[]=$tag['tag_fullname']; } return $tag_names; } /** * @param int $object_id * * @return string|null */ public function getTagsEbookLanguage($object_id) { $tag_group_ids =$this::TAG_PRODUCT_EBOOK_LANGUAGE_GROUPID; $tags = $this->getTagsArray($object_id, $this::TAG_TYPE_PROJECT,$tag_group_ids); $tag_names = array(); foreach ($tags as $tag) { $tag_names[]=$tag['tag_fullname']; } return $tag_names; } /** * @param int $object_id * * @return string|null */ public function getTagsEbookType($object_id) { $tag_group_ids =$this::TAG_PRODUCT_EBOOK_TYPE_GROUPID; $tags = $this->getTagsArray($object_id, $this::TAG_TYPE_PROJECT,$tag_group_ids); $tag_names = array(); foreach ($tags as $tag) { $tag_names[]=$tag['tag_fullname']; } return $tag_names; } } \ No newline at end of file diff --git a/application/modules/default/plugins/InitGlobalStoreVars.php b/application/modules/default/plugins/InitGlobalStoreVars.php index 49427cd44..e45963178 100644 --- a/application/modules/default/plugins/InitGlobalStoreVars.php +++ b/application/modules/default/plugins/InitGlobalStoreVars.php @@ -1,291 +1,302 @@ . **/ class Default_Plugin_InitGlobalStoreVars extends Zend_Controller_Plugin_Abstract { private static $exceptionThrown = false; /** * @param Zend_Controller_Request_Abstract $request * * @throws Zend_Exception */ public function preDispatch(Zend_Controller_Request_Abstract $request) { /** @var Zend_Controller_Request_Http $request */ parent::preDispatch($request); $storeHost = $this->getStoreHost($request); Zend_Registry::set('store_host', $storeHost); $storeConfigName = $this->getStoreConfigName($storeHost); Zend_Registry::set('store_config_name', $storeConfigName); Zend_Registry::set('store_template', $this->getStoreTemplate($storeConfigName)); $config_store = $this->getConfigStore($storeHost); Zend_Registry::set('store_config', $config_store); Zend_Registry::set('config_store_tags', $this->getConfigStoreTags($config_store->store_id)); + Zend_Registry::set('config_store_taggroups', $this->getConfigStoreTagGroups($config_store->store_id)); Zend_Registry::set('store_category_list', $this->getStoreCategories($storeHost)); } /** * @param Zend_Controller_Request_Http $request * * @return mixed * @throws Zend_Exception */ private function getStoreHost($request) { $storeHost = ''; $storeConfigArray = Zend_Registry::get('application_store_config_list'); // search for store id param $requestStoreConfigName = null; if ($request->getParam('domain_store_id')) { $requestStoreConfigName = $request->getParam('domain_store_id') ? preg_replace('/[^-a-zA-Z0-9_\.]/', '', $request->getParam('domain_store_id')) : null; $result = $this->searchForConfig($storeConfigArray, 'name', $requestStoreConfigName); if (isset($result['host'])) { $storeHost = $result['host']; return $storeHost; } } // search for host $httpHost = strtolower($request->getHttpHost()); if (isset($storeConfigArray[$httpHost])) { return $storeConfigArray[$httpHost]['host']; } // search for default $result = $this->searchForConfig($storeConfigArray, 'default', 1); $storeHost = $result['host']; return $storeHost; } /** * alternative version which replace arraySearchConfig for PHP < 5.5.0 * * @param $haystack * @param $key * @param $value * * @return array */ private function searchForConfig($haystack, $key, $value) { if (false === is_array($haystack)) { return array(); } foreach ($haystack as $element) { if (isset($element[$key]) and (strtolower($element[$key]) == strtolower($value))) { return $element; } } return array(); } /** * @param string $storeHostName * * @return string * @throws Zend_Exception */ private function getStoreConfigName($storeHostName) { $storeIdName = Zend_Registry::get('config')->settings->client->default->name; //set to default $store_config_list = Zend_Registry::get('application_store_config_list'); // search for host $httpHost = strtolower($storeHostName); if (isset($store_config_list[$httpHost])) { return $store_config_list[$httpHost]['config_id_name']; } else { Zend_Registry::get('logger')->warn(__METHOD__ . '(' . __LINE__ . ') - $httpHost = ' . $httpHost . ' :: no config id name configured') ; } // search for default $result = $this->searchForConfig($store_config_list, 'default', 1); if (isset($result['config_id_name'])) { $storeIdName = $result['config_id_name']; } else { Zend_Registry::get('logger')->warn(__METHOD__ . '(' . __LINE__ . ') - no default store config name configured'); } return $storeIdName; } /** * @param string $storeConfigName * * @return array|mixed * @throws Zend_Exception */ private function getStoreTemplate($storeConfigName) { $storeTemplate = array(); $fileNameConfig = APPLICATION_PATH . '/configs/client_' . $storeConfigName . '.ini.php'; if (file_exists($fileNameConfig)) { $storeTemplate = require APPLICATION_PATH . '/configs/client_' . $storeConfigName . '.ini.php'; } else { Zend_Registry::get('logger')->warn(__METHOD__ . ' - ' . $storeConfigName . ' :: can not access config file for store context.') ; $this->raiseException(__METHOD__ . ' - ' . $storeConfigName . ' :: can not access config file for store context'); } return $storeTemplate; } /** * @param $message */ private function raiseException($message) { if (self::$exceptionThrown) { return; } $request = $this->getRequest(); // Repoint the request to the default error handler $request->setModuleName('default'); $request->setControllerName('error'); $request->setActionName('error'); //$request->setDispatched(true); // Set up the error handler $error = new Zend_Controller_Plugin_ErrorHandler(); $error->type = Zend_Controller_Plugin_ErrorHandler::EXCEPTION_OTHER; $error->request = clone($request); $error->exception = new Zend_Exception($message); $request->setParam('error_handler', $error); //$this->setRequest($request); self::$exceptionThrown = true; } /** * @param string $storeHostName * * @return Default_Model_ConfigStore */ private function getConfigStore($storeHostName) { $storeConfig = new Default_Model_ConfigStore($storeHostName); return $storeConfig; } private function getConfigStoreTags($store_id) { $modelConfigStoreTags = new Default_Model_ConfigStoreTags(); $result = $modelConfigStoreTags->getTagsAsIdForStore($store_id); return $result; } + + + private function getConfigStoreTagGroups($store_id) + { + $modelConfigStoreTagGroups = new Default_Model_ConfigStoreTagGroups(); + + $result = $modelConfigStoreTagGroups->getTagGroupsAsIdForStore($store_id); + + return $result; + } /** * @param string $storeHostName * * @return array * @throws Zend_Exception */ private function getStoreCategories($storeHostName) { $storeCategoryArray = Zend_Registry::get('application_store_category_list'); //check store_category_list to see if some categories are defined here if (isset($storeCategoryArray[$storeHostName])) { $storeCategories = $storeCategoryArray[$storeHostName]; if (is_string($storeCategories)) { return array($storeCategories); } return $storeCategories; } Zend_Registry::get('logger')->warn(__METHOD__ . '(' . __LINE__ . ') - ' . $storeHostName . ' :: no categories for domain context configured. Try to use categories from default store instead') ; // next step: check store_category_list to see if some categories are defined for the default store $storeConfigArray = Zend_Registry::get('application_store_config_list'); $defaultStore = $this->arraySearchConfig($storeConfigArray, 'default', '1'); if (isset($storeCategoryArray[$defaultStore['host']])) { $storeCategories = $storeCategoryArray[$defaultStore['host']]; if (is_string($storeCategories)) { return array($storeCategories); } return $storeCategories; } Zend_Registry::get('logger')->warn(__METHOD__ . '(' . __LINE__ . ') - ' . $storeHostName . ' :: no categories for default store found. Try to use main categories instead') ; // last chance: take the main categories from the tree $modelCategories = new Default_Model_DbTable_ProjectCategory(); $root = $modelCategories->fetchRoot(); $storeCategories = $modelCategories->fetchImmediateChildrenIds($root['project_category_id'], $modelCategories::ORDERED_TITLE); return $storeCategories; } /** * needs PHP >= 5.5.0 * * @param $haystack * @param $key * @param $needle * * @return array */ private function arraySearchConfig($haystack, $column, $needle) { if (PHP_VERSION_ID <= 50500) { return $this->searchForConfig($haystack, $column, $needle); } if (false === is_array($haystack)) { return array(); } $key = array_search($needle, array_column($haystack, $column, 'host')); if ($key) { return $haystack[$key]; } return array(); } } \ No newline at end of file diff --git a/application/modules/default/views/scripts/explore/index.phtml b/application/modules/default/views/scripts/explore/index.phtml index bf8cf9bd1..ccfea5717 100644 --- a/application/modules/default/views/scripts/explore/index.phtml +++ b/application/modules/default/views/scripts/explore/index.phtml @@ -1,271 +1,298 @@ . **/ $modelCategory = new Default_Model_DbTable_ProjectCategory(); $this->dataCategory = $modelCategory->findSingleRow($this->cat_id); $store_config = Zend_Registry::get('store_config'); $host = $store_config->host; $og_server = $this->serverUrl(true); $catTitle = ''; if($this->dataCategory['project_category_id']) { $catTitle = $this->dataCategory['title']; } if($this->filters['order'] == 'latest'){ $og_title = 'Browse '.$catTitle.' Latest | '.$host; }else if($this->filters['order'] == 'top'){ $og_title = 'Browse '.$catTitle.' Top | '.$host; }else{ $og_title='Browse '.$catTitle.' | '.$host; } $og_description = $og_title .'| A community for free and open source software and libre content'; $this->templateConfigData = Zend_Registry::get('store_template'); $og_image = 'https://' . $_SERVER['HTTP_HOST'] .$this->templateConfigData['logo']; $this->doctype(Zend_View_Helper_Doctype::XHTML1_RDFA); $this->headMeta()->appendProperty('og:type', 'website'); $this->headMeta()->appendProperty('og:url', $og_server); $this->headMeta()->appendProperty('og:title', $og_title); $this->headMeta()->appendProperty('og:site_name',$host); $this->headMeta()->appendProperty('og:description',$og_description); $this->headMeta()->appendProperty('og:image',$og_image); $helperBuildExploreUrl = new Default_View_Helper_BuildExploreUrl(); $modelInfo = new Default_Model_Info(); $this->countSupporters = $modelInfo->getCountAllSupporters(); $this->supporters = $modelInfo->getNewActiveSupporters(7); $this->headLink()->appendStylesheet('/theme/flatui/css/explore_index.css'); if($this->inputFilterOriginal ==1) { $checkedOriginal = ' checked'; }else { $checkedOriginal = ''; } ?>at least 5 chars
'); return false; } jQuery.ajax({ data: $(this).serialize(), url: this.action, type: this.method, dataType: "json", error: function () { $(target).empty().html("Service is temporarily unavailable. Our engineers are working quickly to resolve this issue.More info:
www.linuxuprising.com/2018/04/easily-run-and-integrate-appimage-files.html
'); $('body').on("click", "#btn-ghns-excluded", function(){ var txt = $('#ghns-excluded-text').val(); if(txt.length<5) { alert('min 5 chars'); return false; } var project_id = $(this).attr('data-projectid'); var status = $(this).attr('data-status'); var target = "/backend/project/doghnsexclude"; $.ajax({ url: target, method:'POST', data:{'project_id':project_id,'ghns_excluded':status,'msg':txt}, success: function (results) { var msgBox = $('#generic-dialog'); if (status == 0) { msgBox.find('.modal-body').empty().append('Project is successfully included into GHNS'); $('#ghns_excluded-this-checkbox').prop("checked", false); } else { msgBox.find('.modal-body').empty().append('Project is successfully excluded into GHNS'); $('#ghns_excluded-this-checkbox').prop("checked", true); } setTimeout(function () { msgBox.modal('hide'); }, 1000); }, error: function () { alert('Service is temporarily unavailable.'); } }); }); return false; }); } } })(); var AboutMeMyProjectsPaging = (function () { return { setup: function () { $(window).scroll(function() { var end = $("footer").offset().top; var viewEnd = $(window).scrollTop() + $(window).height(); var distance = end - viewEnd; if (distance < 300){ // } // if($(window).scrollTop() == $(document).height() - $(window).height()) { if(!$('button#btnshowmoreproducts').length) return; let indicator = ''; let nextpage = $('button#btnshowmoreproducts').attr('data-page'); $('button#btnshowmoreproducts').remove(); $url = window.location.href; target = '#my-products-list'; let container = $('
').append(indicator).load($url,{projectpage:nextpage},function (response, status, xhr) { if (status == "error") { if (xhr.status == 401) { if (response) { var data = jQuery.parseJSON(response); var redirect = data.login_url; if (redirect) { window.location = redirect; } else { window.location = "/login"; } } } else { $(target).empty().html('Service is temporarily unavailable. Our engineers are working quickly to resolve this issue.