当前位置: 首页>>代码示例>>PHP>>正文


PHP Label::Insert方法代码示例

本文整理汇总了PHP中Label::Insert方法的典型用法代码示例。如果您正苦于以下问题:PHP Label::Insert方法的具体用法?PHP Label::Insert怎么用?PHP Label::Insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Label的用法示例。


在下文中一共展示了Label::Insert方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: SetSubProject

 /** Set the subproject id */
 function SetSubProject($subproject)
 {
     if (!empty($this->SubProjectId)) {
         return $this->SubProjectId;
     }
     if (empty($subproject)) {
         return false;
     }
     if (empty($this->ProjectId)) {
         add_log('ProjectId not set' . $subproject, 'Build::SetSubProject', LOG_ERR, $this->ProjectId, $this->Id, CDASH_OBJECT_BUILD, $this->Id);
         return false;
     }
     $query = pdo_query("SELECT id FROM subproject WHERE name='{$subproject}' AND " . "projectid=" . qnum($this->ProjectId) . " AND endtime='1980-01-01 00:00:00'");
     if (!$query) {
         add_last_sql_error("Build:SetSubProject()", $this->ProjectId);
         return false;
     }
     $this->SubProjectName = $subproject;
     if (pdo_num_rows($query) > 0) {
         $query_array = pdo_fetch_array($query);
         $this->SubProjectId = $query_array['id'];
         return $this->SubProjectId;
     }
     // If the subproject wasn't found, add it here.
     // A proper Project.xml file will still need to be uploaded later to
     // load dependency data.
     $subProject = new SubProject();
     $subProject->SetProjectId($this->ProjectId);
     $subProject->SetName($subproject);
     $subProject->Save();
     // Insert the label too.
     $Label = new Label();
     $Label->Text = $subProject->GetName();
     $Label->Insert();
     add_log('New subproject detected: ' . $subproject, 'Build::SetSubProject', LOG_WARNING, $this->ProjectId, $this->Id, CDASH_OBJECT_BUILD, $this->Id);
     return true;
 }
开发者ID:josephsnyder,项目名称:CDash,代码行数:38,代码来源:build.php

示例2: startElement

 /** startElement function */
 public function startElement($parser, $name, $attributes)
 {
     parent::startElement($parser, $name, $attributes);
     // Check that the project name matches
     if ($name == 'PROJECT') {
         if (get_project_id($attributes['NAME']) != $this->projectid) {
             add_log("Wrong project name: " . $attributes['NAME'], "ProjectHandler::startElement", LOG_ERR, $this->projectid);
             $this->ProjectNameMatches = false;
         }
     }
     if (!$this->ProjectNameMatches) {
         return;
     }
     if ($name == 'PROJECT') {
         $this->SubProjects = array();
         $this->Dependencies = array();
     } else {
         if ($name == 'SUBPROJECT') {
             $this->SubProject = new SubProject();
             $this->SubProject->SetProjectId($this->projectid);
             $this->SubProject->SetName($attributes['NAME']);
             if (array_key_exists("GROUP", $attributes)) {
                 $this->SubProject->SetGroup($attributes['GROUP']);
             }
             $this->SubProject->Save();
             // Insert the label
             $Label = new Label();
             $Label->Text = $this->SubProject->GetName();
             $Label->Insert();
             $this->SubProjects[$this->SubProject->GetId()] = $this->SubProject;
             $this->Dependencies[$this->SubProject->GetId()] = array();
         } else {
             if ($name == 'DEPENDENCY') {
                 // A DEPENDENCY is expected to be:
                 //
                 //  - another subproject that already exists (from a previous element in
                 //      this submission)
                 //
                 $dependentProject = new SubProject();
                 $dependentProject->SetName($attributes['NAME']);
                 $dependentProject->SetProjectId($this->projectid);
                 // The subproject's Id is automatically loaded once its name & projectid
                 // are set.
                 $dependencyid = $dependentProject->GetId();
                 $added = false;
                 if ($dependencyid !== false && is_numeric($dependencyid)) {
                     if (array_key_exists($dependencyid, $this->SubProjects)) {
                         $this->Dependencies[$this->SubProject->GetId()][] = $dependencyid;
                         $added = true;
                     }
                 }
                 if (!$added) {
                     add_log("Project.xml DEPENDENCY of " . $this->SubProject->GetName() . " not mentioned earlier in file: " . $attributes['NAME'], "ProjectHandler:startElement", LOG_WARNING, $this->projectid);
                 }
             } else {
                 if ($name == 'EMAIL') {
                     $email = $attributes['ADDRESS'];
                     // Check if the user is in the database
                     $User = new User();
                     $posat = strpos($email, '@');
                     if ($posat !== false) {
                         $User->FirstName = substr($email, 0, $posat);
                         $User->LastName = substr($email, $posat + 1);
                     } else {
                         $User->FirstName = $email;
                         $User->LastName = $email;
                     }
                     $User->Email = $email;
                     $User->Password = md5($email);
                     $User->Admin = 0;
                     $userid = $User->GetIdFromEmail($email);
                     if (!$userid) {
                         $User->Save();
                         $userid = $User->Id;
                     }
                     // Insert into the UserProject
                     $UserProject = new UserProject();
                     $UserProject->EmailType = 3;
                     // any build
                     $UserProject->EmailCategory = 54;
                     // everything except warnings
                     $UserProject->UserId = $userid;
                     $UserProject->ProjectId = $this->projectid;
                     $UserProject->Save();
                     // Insert the labels for this user
                     $LabelEmail = new LabelEmail();
                     $LabelEmail->UserId = $userid;
                     $LabelEmail->ProjectId = $this->projectid;
                     $Label = new Label();
                     $Label->SetText($this->SubProject->GetName());
                     $labelid = $Label->GetIdFromText();
                     if (!empty($labelid)) {
                         $LabelEmail->LabelId = $labelid;
                         $LabelEmail->Insert();
                     }
                 }
             }
         }
     }
//.........这里部分代码省略.........
开发者ID:rpshaw,项目名称:CDash,代码行数:101,代码来源:project_handler.php

示例3: endElement

 /** endElement function */
 public function endElement($parser, $name)
 {
     parent::endElement($parser, $name);
     global $CDASH_DELETE_OLD_SUBPROJECTS;
     if (!$this->ProjectNameMatches) {
         return;
     }
     if ($name == 'PROJECT') {
         foreach ($this->SubProjects as $subproject) {
             if ($CDASH_DELETE_OLD_SUBPROJECTS) {
                 // Remove dependencies that do not exist anymore,
                 // but only for those relationships where both sides
                 // are present in $this->SubProjects.
                 //
                 $dependencyids = $subproject->GetDependencies();
                 $removeids = array_diff($dependencyids, $this->Dependencies[$subproject->GetId()]);
                 foreach ($removeids as $removeid) {
                     if (array_key_exists($removeid, $this->SubProjects)) {
                         $subproject->RemoveDependency($removeid);
                     } else {
                         $dep = pdo_get_field_value("SELECT name FROM subproject WHERE id='{$removeid}'", 'name', "{$removeid}");
                         add_log("Not removing dependency {$dep}({$removeid}) from " . $subproject->GetName() . 'because it is not a SubProject element in this Project.xml file', 'ProjectHandler:endElement', LOG_WARNING, $this->projectid);
                     }
                 }
             }
             // Add dependencies that were queued up as we processed the DEPENDENCY
             // elements:
             //
             foreach ($this->Dependencies[$subproject->GetId()] as $addid) {
                 if (array_key_exists($addid, $this->SubProjects)) {
                     $subproject->AddDependency($addid);
                 } else {
                     add_log('impossible condition: should NEVER see this: unknown DEPENDENCY clause should prevent this case', 'ProjectHandler:endElement', LOG_WARNING, $this->projectid);
                 }
             }
         }
         if ($CDASH_DELETE_OLD_SUBPROJECTS) {
             // Delete old subprojects that weren't included in this file.
             $previousSubProjectIds = $this->Project->GetSubProjects();
             foreach ($previousSubProjectIds as $previousId) {
                 $found = false;
                 foreach ($this->SubProjects as $subproject) {
                     if ($subproject->GetId() == $previousId) {
                         $found = true;
                         break;
                     }
                 }
                 if (!$found) {
                     $subProjectToRemove = new SubProject();
                     $subProjectToRemove->SetId($previousId);
                     $subProjectToRemove->Delete();
                     add_log("Deleted " . $subProjectToRemove->GetName() . " because it was not mentioned in Project.xml", 'ProjectHandler:endElement', LOG_WARNING, $this->projectid);
                 }
             }
         }
     } elseif ($name == 'SUBPROJECT') {
         // Insert the SubProject.
         $this->SubProject->Save();
         // Insert the label.
         $Label = new Label();
         $Label->Text = $this->SubProject->GetName();
         $Label->Insert();
         $this->SubProjects[$this->SubProject->GetId()] = $this->SubProject;
         // Handle dependencies here too.
         $this->Dependencies[$this->SubProject->GetId()] = array();
         foreach ($this->CurrentDependencies as $dependencyid) {
             $added = false;
             if ($dependencyid !== false && is_numeric($dependencyid)) {
                 if (array_key_exists($dependencyid, $this->SubProjects)) {
                     $this->Dependencies[$this->SubProject->GetId()][] = $dependencyid;
                     $added = true;
                 }
             }
             if (!$added) {
                 add_log('Project.xml DEPENDENCY of ' . $this->SubProject->GetName() . ' not mentioned earlier in file.', 'ProjectHandler:endElement', LOG_WARNING, $this->projectid);
             }
         }
         // Check if the user is in the database.
         $User = new User();
         $posat = strpos($this->Email, '@');
         if ($posat !== false) {
             $User->FirstName = substr($this->Email, 0, $posat);
             $User->LastName = substr($this->Email, $posat + 1);
         } else {
             $User->FirstName = $this->Email;
             $User->LastName = $this->Email;
         }
         $User->Email = $this->Email;
         $User->Password = md5($this->Email);
         $User->Admin = 0;
         $userid = $User->GetIdFromEmail($this->Email);
         if (!$userid) {
             $User->Save();
             $userid = $User->Id;
         }
         // Insert into the UserProject
         $UserProject = new UserProject();
         $UserProject->EmailType = 3;
         // any build
//.........这里部分代码省略.........
开发者ID:kitware,项目名称:cdash,代码行数:101,代码来源:project_handler.php

示例4: SetSubProject

 /** Set the subproject id */
 public function SetSubProject($subproject)
 {
     if (!empty($this->SubProjectId)) {
         return $this->SubProjectId;
     }
     if (empty($subproject)) {
         return false;
     }
     if (empty($this->ProjectId)) {
         add_log('ProjectId not set' . $subproject, 'Build::SetSubProject', LOG_ERR, $this->ProjectId, $this->Id, CDASH_OBJECT_BUILD, $this->Id);
         return false;
     }
     $query = pdo_query("SELECT id FROM subproject WHERE name='{$subproject}' AND " . 'projectid=' . qnum($this->ProjectId) . " AND endtime='1980-01-01 00:00:00'");
     if (!$query) {
         add_last_sql_error('Build:SetSubProject()', $this->ProjectId);
         return false;
     }
     $this->SubProjectName = $subproject;
     $label = new Label();
     $label->Text = $subproject;
     $this->AddLabel($label);
     // Add this subproject as a label on the parent build.
     $this->SetParentId($this->LookupParentBuildId());
     if ($this->ParentId > 0) {
         $parent = new Build();
         $parent->Id = $this->ParentId;
         $parent->AddLabel($label);
         $parent->InsertLabelAssociations();
     }
     if (pdo_num_rows($query) > 0) {
         $query_array = pdo_fetch_array($query);
         $this->SubProjectId = $query_array['id'];
         return $this->SubProjectId;
     }
     // If the subproject wasn't found, add it here.
     // A proper Project.xml file will still need to be uploaded later to
     // load dependency data.
     $subProject = new SubProject();
     $subProject->SetProjectId($this->ProjectId);
     $subProject->SetName($subproject);
     $subProject->Save();
     // Insert the label too.
     $Label = new Label();
     $Label->Text = $subProject->GetName();
     $Label->Insert();
     add_log('New subproject detected: ' . $subproject, 'Build::SetSubProject', LOG_INFO, $this->ProjectId, $this->Id, CDASH_OBJECT_BUILD, $this->Id);
     return true;
 }
开发者ID:kitware,项目名称:cdash,代码行数:49,代码来源:build.php


注:本文中的Label::Insert方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。