Ejemplo n.º 1
0
 public function linkToHistory($object, $params)
 {
     if (!$object->getTable()->isVersionable()) {
         return '';
     }
     return '<li class="sf_admin_action_history">' . link_to1(__($params['label']), $this->getRouteArrayForAction('history', $object), array('class' => 'sf_admin_action s16 s16_clock_history', 'title' => __($params['title'], array('%1%' => dmString::strtolower(__($this->getModule()->getName())))))) . '</li>';
 }
Ejemplo n.º 2
0
 public function listenToConfigUpdatedEvent(sfEvent $event)
 {
     $setting = $event['setting'];
     if ('internal' == dmString::strtolower($setting->groupName)) {
         return;
     }
     $this->log(array('server' => $_SERVER, 'action' => 'update', 'type' => 'config', 'subject' => sprintf('%s = %s ( %s )', $setting->name, dmString::truncate($setting->value, 80), $event['culture'])));
 }
 public function linkToImportSentences($object, $params)
 {
     if ($this->module->getSecurityManager()->userHasCredentials('edit', $object)) {
         $title = __(isset($params['title']) ? $params['title'] : $params['label'], array('%1%' => dmString::strtolower(__($this->getModule()->getName()))), 'dm');
         return '<li class="sf_admin_action_import_sentences">' . link_to1(__($params['label'], array(), $this->getI18nCatalogue()), $this->getRouteArrayForAction('importSentences', $object), array('class' => 's16 s16_save dm_import_link sf_admin_action', 'title' => $title)) . '</li>';
     }
     return '';
 }
 public function linkTo_preview($object, $params)
 {
     if ($this->module->getSecurityManager()->userHasCredentials('edit', $object)) {
         $title = __(isset($params['title']) ? $params['title'] : $params['label'], array('%1%' => dmString::strtolower(__($this->getModule()->getName()))), 'dm');
         return '<li class="sf_admin_action_preview">' . link_to1(__($params['label'], array(), $this->getI18nCatalogue()), $this->getRouteArrayForAction('preview', $object), array('class' => 's16 s16_right_little dm_preview_link sf_admin_action', 'title' => $title, 'method' => 'get')) . '</li>';
     }
     return '';
 }
Ejemplo n.º 5
0
 public function renderLabel()
 {
     if ($widgetType = $this->getOption('widget_type')) {
         return sprintf('<span class="widget_add move" id="dmwa_%s-%s">%s</span>', $widgetType->getModule(), $widgetType->getAction(), dmString::strtolower(parent::renderLabel()));
     } elseif ($widget = $this->getOption('clipboard_widget')) {
         return sprintf('<span class="widget_paste move dm_%s" id="dmwp_%d">%s</span>', $this->getOption('clipboard_method'), $widget->get('id'), dmString::strtolower(parent::renderLabel()));
     } elseif ($this->getOption('root_add')) {
         return '<a class="tipable s24block s24_add widget24" title="' . $this->__('Add widgets') . '"></a>';
     }
     return '<a>' . dmString::strtolower(parent::renderLabel()) . '</a>';
 }
 public function renderLabel()
 {
     if ($this->getOption('behavior_key')) {
         return sprintf('<span class="behavior_add move" id="dmba_%s"><img src="%s" width="16" height="16" />%s</span>', $this->getOption('behavior_key'), $this->getOption('behavior_icon'), parent::renderLabel());
     } elseif ($this->getOption('clipboard_action')) {
         return sprintf('<span class="behavior_add clipboard %s move" id="dmba_clipboard_behavior_id_%s"><img src="%s" width="16" height="16" />%s</span>', $this->getOption('clipboard_action'), $this->getOption('clipboard_id'), $this->getOption('clipboard_icon'), dmString::strtolower(parent::renderLabel()));
     } elseif ($this->getOption('root_add')) {
         return '<a class="tipable s24block s24_gear widget24" title="' . $this->__('Add behaviors') . '"></a>';
     }
     return '<a>' . dmString::strtolower(parent::renderLabel()) . '</a>';
 }
Ejemplo n.º 7
0
 public function render()
 {
     $preparedAttributes = $this->prepareAttributesForHtml($this->options);
     $tagName = $preparedAttributes['tag'];
     unset($preparedAttributes['tag']);
     if ($tagName === 'span') {
         unset($preparedAttributes['href'], $preparedAttributes['target'], $preparedAttributes['title']);
     }
     $text = $this->renderText();
     if (isset($preparedAttributes['title']) && dmString::strtolower($preparedAttributes['title']) == dmString::strtolower($text)) {
         unset($preparedAttributes['title']);
     }
     return $this->doRender($tagName, $this->convertAttributesToHtml($preparedAttributes), $text);
 }
Ejemplo n.º 8
0
 public static function cleanText($text)
 {
     return trim(preg_replace('|\\s{2,}|', ' ', preg_replace('|\\W|', ' ', dmString::strtolower(dmString::transliterate(strip_tags(str_replace(array("\n", '<'), array(' ', ' <'), $text)))))));
 }
 public function executeBatch(sfWebRequest $request)
 {
     if (!($ids = $request->getParameter('ids'))) {
         $this->getUser()->setFlash('error', 'You must at least select one item.');
         $this->redirect('@' . $this->getDmModule()->getUnderscore());
     }
     foreach ($request->getParameterHolder()->getAll() as $key => $value) {
         if (strncmp($key, 'batch', 5) === 0) {
             $action = $key;
             break;
         }
     }
     if (!isset($action)) {
         $this->getUser()->setFlash('error', 'You must select an action to execute on the selected items.');
         $this->redirect('@' . $this->getDmModule()->getUnderscore());
     }
     if (!method_exists($this, $method = 'execute' . ucfirst($action))) {
         throw new InvalidArgumentException(sprintf('You must create a "%s" method for action "%s"', $method, $action));
     }
     if (!$this->getUser()->hasCredential($this->configuration->getCredentials($action))) {
         $this->forward(sfConfig::get('sf_secure_module'), sfConfig::get('sf_secure_action'));
     }
     $validator = new sfValidatorDoctrineChoice(array('multiple' => true, 'model' => $this->getDmModule()->getModel()));
     try {
         // validate ids
         $ids = $validator->clean($ids);
         //@todo add record security check here ! using dmModuleSecurityManager, create new method in it
         //if there are some ids for which user can't execute the method, remove them, then execute them
         //something like
         $_action = substr($action, 5);
         $_action = dmString::strtolower($_action);
         $authorizedIdsForAction = $this->getDmModule()->getSecurityManager()->getIdsForAuthorizedActionWithinIds($_action, $this->getUser()->getUser(), $ids);
         if (!$authorizedIdsForAction) {
             throw new LogicException('You cannot delete those elements because you are not authorized to do so.', 401);
         }
         if (count($ids) != count($authorizedIdsForAction)) {
             $request->setParameter('excluded_ids', array_diff($ids, $authorizedIdsForAction));
         }
         $request->setParameter('ids', $authorizedIdsForAction);
         // execute batch
         $this->{$method}($request);
     } catch (sfValidatorError $e) {
         $this->getUser()->setFlash('error', 'A problem occurs when deleting the selected items as some items do not exist anymore. ');
     } catch (LogicException $e) {
         $this->getUser()->setFlash('error', $e->getMessage());
     }
     $this->redirect('@' . $this->getDmModule()->getUnderscore());
 }