public function beforeSave() { $name = $this->getProperty('tag'); $group = $this->getProperty('group'); $alias = $this->getProperty('alias'); if (empty($name) || empty($group)) { if (empty($group)) { $this->addFieldError('group', $this->modx->lexicon('tagger.err.group_name_ns')); } if (empty($name)) { $this->addFieldError('tag', $this->modx->lexicon('tagger.err.tag_name_ns')); } } else { if ($this->object->group != $group) { $this->addFieldError('group', $this->modx->lexicon('tagger.err.tag_group_changed')); } if ($this->modx->getCount($this->classKey, array('tag' => $name, 'group' => $group, 'id:!=' => $this->object->id)) > 0) { $this->addFieldError('tag', $this->modx->lexicon('tagger.err.tag_name_ae')); } } if (!empty($alias)) { $alias = $this->object->cleanAlias($alias); if ($this->modx->getCount($this->classKey, array('alias' => $alias, 'group' => $group, 'id:!=' => $this->object->id)) > 0) { $this->addFieldError('alias', $this->modx->lexicon('tagger.err.tag_alias_ae')); } else { $this->object->set('alias', $alias); } } return parent::beforeSave(); }
public function beforeSave() { $name = $this->getProperty('tag'); $group = $this->getProperty('group'); $alias = $this->getProperty('alias'); if (empty($name) || empty($group)) { if (empty($group)) { $this->addFieldError('group', $this->modx->lexicon('tagger.err.group_name_ns')); } if (empty($name)) { $this->addFieldError('tag', $this->modx->lexicon('tagger.err.tag_name_ns')); } } else { if ($this->doesAlreadyExist(array('tag' => $name, 'group' => $group))) { $this->addFieldError('tag', $this->modx->lexicon('tagger.err.tag_name_ae')); } } if (!empty($alias)) { $alias = $this->object->cleanAlias($alias); if ($this->doesAlreadyExist(array('alias' => $alias, 'group' => $group))) { $this->addFieldError('alias', $this->modx->lexicon('tagger.err.tag_alias_ae')); } } return parent::beforeSave(); }
/** * Ends relationship between page and tag * * @since 1.1.0 * * @param string $ids */ public function endrelationship($ids) { $id = explode('-', $ids); $page_id = $id[0]; $tag_id = $id[1]; if ($page = Record::findByIdFrom('Page', $page_id)) { if ($tag = Record::findByIdFrom('Tag', $tag_id)) { if (TaggerTag::deletePageTagRelationship($page_id, $tag_id)) { Flash::set('success', __('Page :page_name has been deleted from association with Tag :tag_name!', array(':page_name' => $page->title, ':tag_name' => $tag->name))); } else { Flash::set('error', __('Nothing was deleted!')); } } } else { Flash::set('error', __('Page not found!')); } redirect(get_url('plugin/tagger')); }
?> (<?php echo $tag->count; ?> )</a> <?php $tagCount = count(TaggerTag::findTagsAndPageAssigned($tag->id)); if ($tagCount > 0) { $n = 0; ?> <ul class="tagged"> <?php echo __('tagged:'); ?> <?php foreach (TaggerTag::findTagsAndPageAssigned($tag->id) as $page_id => $title) { $n++; ?> <li id="<?php echo $page_id; ?> "> <a href="<?php echo get_url('page/edit/' . $page_id); ?> "><?php echo $title; ?> </a> <a href="<?php echo get_url('plugin/tagger/endrelationship/' . $page_id . '-' . $tag->id);