public function viewAction() { $fullPath = $this->getFullPath(); $pipelineMapper = new Pipeline_Model_Mapper_Pipeline(); $pipeline = $pipelineMapper->findByFulPath($fullPath, new Pipeline_Model_Pipeline()); if (is_null($pipeline)) { throw new Zend_Controller_Action_Exception("Страница не найдена", 404); } $this->getJson($pipeline); $this->setParamsDataItem($pipeline); $this->checkDeleted($pipeline); $categoriesMapper = new Pipeline_Model_Mapper_PipelineCategories(); $category = $categoriesMapper->find($pipeline->getCategoryId(), new Pipeline_Model_PipelineCategories()); $pipelineProperties = $pipelineMapper->fetchPropertyRel($pipeline->getId()); if (!empty($pipelineProperties)) { $propertyValuesMapper = new Pipeline_Model_Mapper_PipelinePropertyValues(); $viewProperties = array(); foreach ($pipelineProperties as $property) { $propertyValues = $propertyValuesMapper->findByKey($pipeline->getId(), $property->getId(), new Pipeline_Model_PipelinePropertyValues()); $viewProperties[$property->getName()] = $propertyValues; } $this->view->assign('properties', $viewProperties); } $this->view->assign(array('pipeline' => $pipeline, 'category' => $category, 'title' => $pipeline->getTitle(), 'adminPath' => 'pipeline/edit/' . $pipeline->getId())); $this->checkActive($pipeline); }
/** * @param $pipeline_id * @return array */ function GetPipelineProperties($pipeline_id) { $pipelineMapper = new Pipeline_Model_Mapper_Pipeline(); $pipelineProperties = $pipelineMapper->fetchPropertyRel($pipeline_id); $properties = array(); if (!empty($pipelineProperties)) { $propertyValuesMapper = new Pipeline_Model_Mapper_PipelinePropertyValues(); foreach ($pipelineProperties as $property) { $propertyValues = $propertyValuesMapper->findByKey($pipeline_id, $property->getId(), new Pipeline_Model_PipelinePropertyValues()); $properties[$property->getName()] = $propertyValues; } } return $properties; }
/** * @param $itemId * @return array * */ protected function _getPropertyArray($itemId) { $pipelinePropertyMapper = new Pipeline_Model_Mapper_PipelineProperty(); $select = $pipelinePropertyMapper->getDbTable()->select(); $select->where('deleted != ?', 1)->where('active != ?', 0)->order('sorting ASC'); $pipelinePropertyArray = array(); $pipelinePropertyArray[] = '...'; $pipelineProperty = $pipelinePropertyMapper->fetchAll($select); $pipelinePropertyValuesMapper = new Pipeline_Model_Mapper_PipelinePropertyValues(); $select = $pipelinePropertyValuesMapper->getDbTable()->select(); $select->where('pipeline_id = ?', $itemId); $pipelinePropertyValuesArray = $pipelinePropertyValuesMapper->fetchAll($select); $itemIdArray = array(); if (!empty($pipelinePropertyValuesArray)) { foreach ($pipelinePropertyValuesArray as $pipelinePropertyValue) { $itemIdArray[] = $pipelinePropertyValue->getPropertyId(); } } if (!empty($pipelineProperty)) { foreach ($pipelineProperty as $property) { if (!in_array($property->getId(), $itemIdArray)) { $pipelinePropertyArray[$property->getId()] = $property->getName(); } } } $pipelinePropertyArray['new'] = 'Новое'; return $pipelinePropertyArray; }