本文整理汇总了PHP中Tag::setName方法的典型用法代码示例。如果您正苦于以下问题:PHP Tag::setName方法的具体用法?PHP Tag::setName怎么用?PHP Tag::setName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tag
的用法示例。
在下文中一共展示了Tag::setName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: newTag
/**
* @param sfGuardUser $user
* @param integer $element_id
* @param string $name
* @param string $type
*/
public static function newTag($user, $element_id, $name, $type)
{
$tag = TagTable::getInstance()->findOneByNameAndUserId($name, $user->id);
if (!$tag) {
$tag = new Tag();
$tag->setName(substr($name, 0, self::MAX_LENGTH));
$tag->setUserId($user->id);
$tag->save();
}
if ($type == 'decision') {
$tagDecision = new TagDecision();
$tagDecision->setDecisionId($element_id);
$tagDecision->setTagId($tag->id);
$tagDecision->save();
} else {
if ($type == 'release') {
$tagRelease = new TagRelease();
$tagRelease->setReleaseId($element_id);
$tagRelease->setTagId($tag->id);
$tagRelease->save();
} else {
$tagAlternative = new TagAlternative();
$tagAlternative->setAlternativeId($element_id);
$tagAlternative->setTagId($tag->id);
$tagAlternative->save();
Doctrine_Query::create()->delete('Graph')->where('decision_id = ?', $tagAlternative->Alternative->decision_id)->execute();
}
}
return;
}
示例2: executeTag
public function executeTag()
{
$this->forwardUnless($this->getUser()->getBlog()->getApproved(), 'ucp', 'index');
if ($this->getRequest()->getMethod() == sfRequest::POST) {
$tag = new Tag();
$tag->setName(Tag::tagize($this->getRequestParameter('name')));
$tag->save();
$this->setFlash('updated', 'Tag został zgłoszony do dodania.');
return $this->redirect('ucp/index');
}
}
示例3: createFromResponse
public static function createFromResponse(\SimpleXMLElement $response)
{
$tag = new Tag();
$tag->setName((string) $response->name);
$tag->setCount((int) $response->count);
$tag->setUrl((string) $response->url);
$tag->setReach((int) $response->reach);
$tag->setTaggings((int) $response->taggings);
$tag->setStreamable((int) $response->streamable);
$tag->setPublished((string) $response->wiki->published);
$tag->setSummary((string) $response->wiki->summary);
$tag->setContent((string) $response->wiki->content);
return $tag;
}
示例4: saveTag
public function saveTag($tag, $foreignId, $foreignTable, $memberId, $communityId = null)
{
if ($tag != "") {
$obj = $this->createQuery()->where("member_id=?", $memberId)->addWhere("foreign_table=?", $foreignTable)->addWhere("foreign_id=?", $foreignId)->addWhere("name=?", $tag)->fetchOne();
if (!$obj) {
$obj = new Tag();
$obj->setMemberId($memberId);
if ($communityId) {
$obj->setCommunityId($communityId);
}
$obj->setForeignTable($foreignTable);
$obj->setForeignId($foreignId);
$obj->setName($tag);
$obj->save();
}
}
}
示例5: getForCloud
public static function getForCloud()
{
$connection = Propel::getConnection(self::DATABASE_NAME);
$query = 'SELECT %5$s as name, COUNT(%3$s) AS count FROM `%1$s` ';
$query .= 'LEFT JOIN `%2$s` ON %3$s = %4$s GROUP BY %4$s ORDER BY %5$s ASC';
$query = sprintf($query, self::TABLE_NAME, PostTagPeer::TABLE_NAME, PostTagPeer::TAG_ID, self::ID, self::NAME);
$statement = $connection->prepareStatement($query);
$rs = $statement->executeQuery();
$tags = array();
while ($rs->next()) {
$tag = new Tag();
$tag->setName($rs->getString('name'));
$tag->setCount($rs->getInt('count'));
$tags[] = $tag;
}
return $tags;
}
示例6: newTagInstance
public static function newTagInstance($sTagName, $sModelName, $iTaggedItemId)
{
$sTagName = StringUtil::normalize($sTagName);
$oTag = TagPeer::retrieveByName($sTagName);
if ($oTag === null) {
$oTag = new Tag();
$oTag->setName($sTagName);
$oTag->save();
}
$oTagInstance = self::retrieveByPK($oTag->getId(), $iTaggedItemId, $sModelName);
if ($oTagInstance !== null) {
throw new Exception("Instance of this tag does already exist");
}
$oTagInstance = new TagInstance();
$oTagInstance->setTag($oTag);
$oTagInstance->setModelName($sModelName);
$oTagInstance->setTaggedItemId($iTaggedItemId);
$oTagInstance->save();
return $oTagInstance;
}
示例7: realpath
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
require realpath(dirname(__FILE__)) . '/../../../common/Loader.php';
require realpath(dirname(__FILE__)) . '/../Html.php';
// Instantiate the HTML module
$html = new HtmlModule($pakiti);
/* TEMPORARY SENT FORM */
if (Utils::getHttpPostVar("tag-create-form") == "sent") {
$cveName = Utils::getHttpPostVar("cve-name");
$tagName = Utils::getHttpPostVar("cve-tag");
$tagReason = Utils::getHttpPostVar("tag-reason");
$tag = new Tag();
$tag->setName($tagName);
$tag->setReason($tagReason);
$cves = $pakiti->getManager("CveDefsManager")->getCvesByName($cveName);
try {
foreach ($cves as $cve) {
$pakiti->getManager("TagsManager")->assignTagToCve($cve, $tag);
}
$html->setMessage(sprintf("Tag %s has been associated to %s.", $tagName, $cveName));
} catch (Exception $e) {
$html->setMessage(sprintf("%s", $e->getMessage()));
}
}
$html->addHtmlAttribute("title", "CVE Tags overview");
$html->printHeader();
$cveNames = $pakiti->getManager("CveDefsManager")->getCveNames();
$cvesWithTags = $pakiti->getManager("CveDefsManager")->getCvesWithTags();
示例8: addTagTo
/**
* Add a tag to the Page given by the id
*/
public static function addTagTo($sPageId, $mTag)
{
if ($mTag instanceof TagInstance) {
$mTag = $mTag->getTag();
}
if ($mTag instanceof Tag) {
$mTag = $mTag->getName();
}
$sTagName = StringUtil::normalize($mTag);
$oTag = TagQuery::create()->findOneByName($sTagName);
if ($oTag === null) {
$oTag = new Tag();
$oTag->setName($sTagName);
$oTag->save();
}
$oTagInstance = TagInstanceQuery::create()->findPk(array($oTag->getId(), $sPageId, "Page"));
if ($oTagInstance !== null) {
return $oTagInstance;
}
$oTagInstance = new TagInstance();
$oTagInstance->setTag($oTag);
$oTagInstance->setModelName("Page");
$oTagInstance->setTaggedItemId($sPageId);
$oTagInstance->save();
return $oTagInstance;
}
示例9: onCheckNewTag
protected function onCheckNewTag($data)
{
$tag = new Tag();
$tag->setName($data['tag']);
$tag->saveIfNotExist();
}
示例10: retrieveOrCreateByTagname
/**
* Retrieves a tag by his name. If it does not exist, creates it (but does not
* save it)
*
* @param String $tagname
* @return Tag
*/
public static function retrieveOrCreateByTagname($tagname)
{
// retrieve or create the tag
$tag = TagPeer::retrieveByTagName($tagname);
if (!$tag) {
$tag = new Tag();
$tag->setName($tagname);
$triple = sfPropelActAsTaggableToolkit::extractTriple($tagname);
list($tagname, $triple_namespace, $triple_key, $triple_value) = $triple;
$tag->setTripleNamespace($triple_namespace);
$tag->setTripleKey($triple_key);
$tag->setTripleValue($triple_value);
$tag->setIsTriple(!is_null($triple_namespace));
}
return $tag;
}
示例11: executeUpdate
public function executeUpdate()
{
$id = $this->getRequestParameter('id');
if (!$id) {
$snippet = new Snippet();
} else {
$snippet = SnippetPeer::retrieveByPk($id);
$this->forward404Unless($snippet);
if ($snippet->getUserId() != $this->getUser()->getGuardUser()->getId()) {
$this->forward('default', 'secure');
}
foreach ($snippet->getTags() as $tag) {
$tag->delete();
}
$snippet = SnippetPeer::retrieveByPk($id);
}
if ($this->getUser()->isAuthenticated()) {
$snippet->setUserId($this->getUser()->getGuardUser()->getId());
} else {
$snippet->setName($this->getRequestParameter('name'));
$snippet->setEmail($this->getRequestParameter('email'));
}
$snippet->setTitle($this->getRequestParameter('title'));
$snippet->setRawBody($this->getRequestParameter('raw_body'));
$snippet->setBody(null);
$tag_names = explode(',', $this->getRequestParameter('tags'));
foreach ($tag_names as $tag_name) {
if (!($tag_name = strtolower(trim($tag_name)))) {
continue;
}
$tag = new Tag();
$tag->setName($tag_name);
$snippet->addTag($tag);
}
if ($this->getUser()->hasGroup('EDITOR')) {
if ($this->getRequestParameter('managed_content')) {
$snippet->setManagedContent(1);
} else {
$snippet->setManagedContent(0);
}
}
$draft = $this->getRequestParameter('draft');
if (!isset($draft)) {
$snippet->setDraft(false);
} else {
$snippet->setDraft($draft);
}
$snippet->save();
return $this->redirect('snippet/show?id=' . $snippet->getFriendlyUrl());
}
示例12: HandleTags
/**
* Handles
* a) the adding of new Tags to the database,
* b) the deleting of all existing Tag2All for this Model|Set|Image|Video and
* c) inserting the appropriate Tag2All records for this Model|Set|Image|Video
* @param array(string) $newTags
* @param array(Tag2All) $Tag2AllsThisItem
* @param array(Tag) $TagsInDB, passed by reference
* @param User $CurrentUser
* @param int $ModelID
* @param int $SetID
* @param int $ImageID
* @param int $VideoID
* @param bool $DeleteOldTag2Alls determines whether to delete or merge existing Tag2Alls
*/
public static function HandleTags($newTags, $Tag2AllsThisItem, &$TagsInDB, $CurrentUser, $ModelID = NULL, $SetID = NULL, $ImageID = NULL, $VideoID = NULL, $DeleteOldTag2Alls = TRUE)
{
global $db;
foreach (array_unique($newTags) as $string) {
$tInDB = Tag::Filter($TagsInDB, NULL, $string);
if (!$tInDB) {
$tNew = new Tag();
$tNew->setName(trim($string));
if (Tag::Insert($tNew, $CurrentUser)) {
$TagsInDB[] = $tNew;
}
}
}
if ($DeleteOldTag2Alls) {
self::DeleteMulti($Tag2AllsThisItem, $CurrentUser);
}
foreach (array_unique($newTags) as $string) {
$tInDB = Tag::Filter($TagsInDB, NULL, $string);
if (!$DeleteOldTag2Alls) {
$ttits = self::Filter($Tag2AllsThisItem, $tInDB[0]->getID(), $ModelID, $SetID, $ImageID, $VideoID);
if ($ttits) {
continue;
}
}
$t2a = new Tag2All();
$t2a->setTag($tInDB[0]);
if (!is_null($ModelID)) {
$t2a->setModelID($ModelID);
}
if (!is_null($SetID)) {
$t2a->setSetID($SetID);
}
if (!is_null($ImageID)) {
$t2a->setImageID($ImageID);
}
if (!is_null($VideoID)) {
$t2a->setVideoID($VideoID);
}
if ($t2a->getModelID() || $t2a->getSetID() || $t2a->getImageID() || $t2a->getVideoID()) {
Tag2All::Insert($t2a, $CurrentUser);
}
}
}
示例13: assignTagToCve
public function assignTagToCve(Cve &$cve, Tag &$tag)
{
if ($cve == null || $cve->getId() == -1 || $tag == null) {
Utils::log(LOG_DEBUG, "Exception", __FILE__, __LINE__);
throw new Exception("Cve object is not valid or Cve.id is not set");
}
# Check if the tag name is valid
if ($tag->getName() == "") {
$tag->setName(Constants::$NA);
}
$tagId = $this->getTagIdByName($tag->getName());
if ($tagId == -1) {
$this->getPakiti()->getDao("Tag")->create($tag);
} else {
$tag->setId($tagId);
}
Utils::log(LOG_DEBUG, "Assinging the tag to the cve [cveId=" . $cve->getId() . ",tag=" . $tag->getName() . "]", __FILE__, __LINE__);
# Check if the already assigned
$isAssigned = $this->getPakiti()->getManager("DbManager")->queryToSingleValue("select 1 from CveTag where\n \t \t\tcveId=" . $this->getPakiti()->getManager("DbManager")->escape($cve->getId()) . " and\n \t \t\ttagId=" . $this->getPakiti()->getManager("DbManager")->escape($tag->getId()));
if ($isAssigned != null) {
throw new Exception($cve->getName() . " is already associated with " . $tag->getName() . " tag!");
} else {
# Association between cve and cveTag doesn't exist, so create it
$this->getPakiti()->getManager("DbManager")->query("\n \t\tinsert into CveTag set\n \t\t\tcveId=" . $this->getPakiti()->getManager("DbManager")->escape($cve->getId()) . ",\n \t \t\ttagId=" . $this->getPakiti()->getManager("DbManager")->escape($tag->getId()) . ",\n \t \t\t`reason`='" . $this->getPakiti()->getManager("DbManager")->escape($tag->getReason()) . "'");
}
}
示例14: edit
/**
* @param Tag $tag
* @param $values
* @return Tag
*/
protected function edit(Tag $tag, $values)
{
$tag->setName($values->name)->setSlug($values->slug);
$this->tagFacade->save($tag);
return $tag;
}
示例15: prepareReport
public function prepareReport()
{
Utils::log(LOG_DEBUG, "Preparing the report", __FILE__, __LINE__);
$tag = null;
$hostGroup = null;
switch ($this->_version) {
case "4":
Utils::log(LOG_DEBUG, "Client in version 4", __FILE__, __LINE__);
# Get the rest of HTTP variables
# host, os, arch, kernel, site, version, type, pkgs
$this->_host->setOsName($this->_report_os);
$this->_host->setArchName($this->_report_arch);
$this->_host->setKernel($this->_report_kernel);
$this->_host->setType($this->_report_type);
break;
case "cern_1":
Utils::log(LOG_DEBUG, "Client in version CERN 1", __FILE__, __LINE__);
# Get the rest of HTTP variables
# host, os, arch, kernel, site, version, type, pkgs
$this->_host->setOsName($this->_report_os);
$this->_host->setArchName($this->_report_arch);
$this->_host->setKernel($this->_report_kernel);
$this->_host->setType($this->_report_type);
break;
}
# Parse the packages list
$this->_pkgs = $this->parsePkgs($this->_report_pkgs);
# Set the initial information about the report
$this->_report->setReceivedOn(time());
# Get the host object from the DB, if the host doesn't exist in the DB, this routine will create it
$this->_host = $this->getPakiti()->getManager("HostsManager")->getHostFromReport($this->_host, $this->_pkgs);
# Get the host group
$hostGroup = new HostGroup();
$hostGroup->setName($this->_report_site);
# If the host is already member of the host group, no operation is done
$this->getPakiti()->getManager("HostGroupsManager")->assignHostToHostGroup($this->_host, $hostGroup);
# Get the host tag and assign it to the host
$tag = new Tag();
$tag->setName($this->_report_tag);
# If the tag is already assigned, no operation is done
$this->getPakiti()->getManager("TagsManager")->assignTagToHost($this->_host, $tag);
$this->_report->setNumOfInstalledPkgs(sizeof($this->_pkgs));
}