Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

various fixes for translation and default admin mappe

  • Loading branch information...
commit bb48d22c70fb1c685883b071595348ad0893c39d 1 parent a151a25
Florent Jaby Floby authored
1  configs/module.ini
View
@@ -35,6 +35,7 @@ highlight.mappers.default.cover.pixelOnEmpty = 1
;
; the class to instanciate
highlight.crawlers.default.className = "Highlight_Model_Crawler_Default";
+highlight.crawlers.default.useFilters = true
; each key of the config defines a model it has to crawl
; the table config define which table it has to crawl
37 models/Controller/AdminHighlightController.php
View
@@ -247,20 +247,45 @@ public function getAction()
)));
$this->view->autoCompleteForm = $form;
- $this->view->highlightMapper = $this->_getHighlightMapper();
+ $this->view->highlightMapper = $this->getMapper();
$this->render('admin-highlight/get', true, true);
}
/**
- * gets a mapper for the highlights item we want to display.
+ * returns the mapper to be used upon listing of the highlight
+ * @return Highlight_Model_Mapper_Interface
*/
- protected function _getHighlightMapper()
+ public function getMapper()
{
- // return default mapper for now
- return Highlight_Model_FieldMapper_Factory::get('default');
+ // maybe there was a crawler parameter in the url
+ // we can try and find it from config.
+ if($this->_getParam('mapper', false)) {
+ $mapperName = $this->_getParam('mapper');
+ $mapper = Highlight_Model_Mapper_Factory::get($mapperName);
+ }
+
+ // maybe the container is a named container and has a mapper in its config
+ if($container = $this->_getContainer()) {
+ if(!empty($container->name)) {
+ $name = $container->name;
+ $mapperName = Centurion_Config_Manager::get(sprintf('highlight.named_highlights.%s.mapper', $name));
+ if($mapperName) {
+ $mapper = Highlight_Model_FieldMapper_Factory::get($mapperName);
+ }
+ }
+ }
+
+ // if everything else fails, get default mapper
+ if(empty($mapper)) {
+ $mapper = Highlight_Model_FieldMapper_Factory::get('default');
+ }
+
+ // some mappers may need the container we are talking about
+ //$mapper->setContainer($this->_getContainer());
+ return $mapper;
}
-
+
public function addAction()
{
$form = $this->_getAutocompleteForm();
8 models/Crawler/Default.php
View
@@ -12,6 +12,12 @@ public function __construct(array $params)
{
unset($params['className']);
+ $this->_useFilters = true;
+ if(isset($params['useFilters'])) {
+ $this->_useFilters = $params['useFilters'];
+ }
+ unset($params['useFilters']);
+
if(!isset($params['models']) || empty($params['models'])) {
throw new InvalidArgumentException('No models defined for this crawler');
}
@@ -35,7 +41,9 @@ public function crawl(array $params=null)
$fields = (array) $model['fields'];
$limit = (isset($model['limit']) && is_numeric($model['limit'])) ? $model['limit'] : 0;
+ Centurion_Db_Table_Abstract::setFiltersStatus($this->_useFilters);
$res = array_merge($res, $this->crawlTable($table, $fields, $params['terms'], $limit));
+ Centurion_Db_Table_Abstract::restoreFiltersStatus();
}
return $res;
}
7 models/FieldMapper/Default.php
View
@@ -24,7 +24,12 @@ function __construct($params)
continue;
}
- $this->_pixelOnEmpty = $params['cover']['pixelOnEmpty'] > 0;
+ if(isset($params['cover']) && isset($params['cover']['pixelOnEmpty'])) {
+ $this->_pixelOnEmpty = $params['cover']['pixelOnEmpty'] > 0;
+ }
+ else {
+ $this->_pixelOnEmpty = false;
+ }
$this->_fieldMap[$field] = $fields;
}
Please sign in to comment.
Something went wrong with that request. Please try again.