Permalink
Browse files

various fixes for highlights with proxies

  • Loading branch information...
1 parent bb48d22 commit a852022d72212a556ee4e2cf4c7dcb6ff6218efb @Floby Floby committed Sep 19, 2012
View
@@ -34,6 +34,7 @@ public function _initContainers()
foreach ($namedHighlights as $name) {
if(!isset($existing[$name])) {
$containerModel->createWithName($name);
+ $existing[$name] = true;
}
}
}
@@ -38,6 +38,14 @@ public function newAction()
parent::newAction();
}
+ public function postAction()
+ {
+ $container = $this->_getContainer();
+ $this->_getForm()->addElement('hidden', 'container_id', array('value'=>$container->id));
+
+ parent::postAction();
+ }
+
protected function _getContainer()
{
if (!isset($this->_container)) {
@@ -0,0 +1 @@
+ALTER TABLE `highlight_row` CHANGE `proxy_pk` `proxy_pk` VARCHAR( 255 ) CHARACTER SET utf8 NULL DEFAULT NULL;
@@ -235,6 +235,7 @@ public function _getAutocompleteForm()
public function getAction()
{
$this->view->container = $this->_getContainer();
+ $this->view->proxy = $this->_getProxy();
if($backUrl = $this->_getParam('returnafter', false)) {
$this->view->backUrl = urldecode($backUrl);
}
@@ -63,8 +63,11 @@ public function titleGetter()
* @param $limit the maximum number of highlights to return
* @return array of highlights
*/
- public function getHighlights($mapper = 'default', $override = null, $limit = null)
+ public function getHighlights($mapper = null, $override = null, $limit = null)
{
+ if(is_null($mapper)) {
+ $mapper = $this->_getDefaultMapperName();
+ }
if(is_string($mapper)) {
$mapper = Highlight_Model_FieldMapper_Factory::get($mapper, $override);
}
@@ -78,4 +81,18 @@ public function getHighlights($mapper = 'default', $override = null, $limit = nu
return $res;
}
+ /**
+ * Returns the default mapper for this highlight
+ * 'default' is nothing else is defined in config for a named highlight
+ */
+ protected function _getDefaultMapperName()
+ {
+ if(empty($this->name)) {
+ return 'default';
+ }
+ else {
+ return Centurion_Config_Manager::get(sprintf('highlight.named_highlights.%s.mapper', $name), 'default');
+ }
+ }
+
}
@@ -1,5 +1,14 @@
<?php
-$this->placeholder('headling_1')->set('<h1>Manage highlights of: ' . $this->smartTextCrop($this->container->title, 60) . '</h1>');
+if($this->proxy) {
+ $title = $this->translate('Manage highlights of: %s (%s)',
+ $this->smartTextCrop($this->container->title, 60),
+ $this->smartTextCrop($this->proxy->__toString(), 30)
+ );
+}
+else {
+ $title = $this->translate('Manage highlights of: %s', $this->smartTextCrop($this->container->title, 60));
+}
+$this->placeholder('headling_1')->set('<h1>'.$title.'</h1>');
?>
<style type="text/css">
.hl-item {width: 275px; height: 100px;}
@@ -43,8 +52,6 @@ $(function(){
});
});
-var url = {'article' : "<?php echo $this->url(array('module' => 'vinsoc', 'controller' => 'admin-article', 'action' => 'new', '_next' => $this->url(array('id' => $this->container->id, 'action' => 'add', 'position' => '___position___', 'pk' => '___pk___', 'model' => 'Vinsoc_Model_DbTable_Row_Article', 'returnto' => $this->url()))))?>"
- };
$(function(){
@@ -55,10 +62,12 @@ $(function(){
});
});
-
+;
<?php $this->headScript()->captureEnd(); ?>
-
+ <?php if(!empty($this->backUrl)) : ?>
+ <p><a href="<?php echo $this->backUrl ?>"><?php echo $this->translate('Back') ?></a></p>
+ <?php endif ?>
<div>
<?php if(isset($this->errors)) : ?>
<div class="ui-state-message">

0 comments on commit a852022

Please sign in to comment.