private function initTag() { $tag_class = SwatDBClassMap::get('BlorgTag'); $this->tag = new $tag_class(); $this->tag->setDatabase($this->app->db); if (!$this->tag->load($this->id)) { throw new AdminNotFoundException(sprintf(Blorg::_('Tag with id “%s” not found.'), $this->id)); } }
protected function initTag() { $class_name = SwatDBClassMap::get('BlorgTag'); $this->tag = new $class_name(); $this->tag->setDatabase($this->app->db); if (!$this->tag->loadByShortname($this->getArgument('shortname'), $this->app->getInstance())) { throw new SiteNotFoundException('Page not found.'); } }
protected function initTag() { $this->tag = new BlorgTag(); $this->tag->setDatabase($this->app->db); if ($this->id !== null) { if (!$this->tag->load($this->id)) { throw new AdminNotFoundException(sprintf(Blorg::_('Tag with id ‘%s’ not found.'), $this->id)); } $instance_id = $this->tag->getInternalValue('instance'); if ($instance_id !== $this->app->getInstanceId()) { throw new AdminNotFoundException(sprintf(Blorg::_('Tag with id ‘%d’ not found.'), $this->id)); } } }
/** * Creates a new tag * * @throws SwatException if no database connection is set on this tag * entry control. */ protected function insertTag($title, $index) { if ($this->app === null) { throw new SwatException('An application must be set on the tag entry control during ' . 'the widget init phase.'); } // check to see if the tag already exists $instance_id = $this->app->getInstanceId(); $sql = sprintf('select * from BlorgTag where lower(title) = lower(%s) and instance %s %s', $this->app->db->quote($title, 'text'), SwatDB::equalityOperator($instance_id), $this->app->db->quote($instance_id, 'integer')); $tags = SwatDB::query($this->app->db, $sql, SwatDBClassMap::get('BlorgTagWrapper')); // only insert if no tag already exists (prevents creating two tags on // reloading) if (count($tags) > 0) { $tag = $tags->getFirst(); } else { $tag = new BlorgTag(); $tag->setDatabase($this->app->db); $tag->instance = $instance_id; $tag->title = $title; $tag->save(); if (isset($this->app->memcache)) { $this->app->memcache->flushNs('tags'); } $message = new SwatMessage(sprintf(Blorg::_('The tag “%s” has been added.'), $tag->title)); $this->app->messages->add($message); } $this->tag_array[$tag->shortname] = $tag->title; $this->selected_tag_array[$tag->shortname] = $tag->title; }