示例#1
0
function do_add_tmpl()
{
    $inputs = JxBotUtil::inputs('category,new-tmpl');
    JxBotNLData::template_add(intval($inputs['category']), $inputs['new-tmpl']);
    page_edit($inputs['category']);
}
示例#2
0
文件: aiml.php 项目: jhawcroft/jxbot
 public function _element_end($in_parser, $in_name)
 {
     set_time_limit(JxBotAimlImport::IMPORT_TIMEOUT_EXTEND);
     //print '/ '.$in_name.'  '.JxBotAiml::$state.'<br>';
     switch ($this->state) {
         case JxBotAimlImport::STATE_CATEGORY:
             if ($in_name == 'category') {
                 $this->state = JxBotAimlImport::STATE_AIML;
                 $topic = trim($this->cat_topic === null ? $this->aiml_topic : $this->cat_topic);
                 $that = trim($this->cat_that);
                 $category_id = JxBotNLData::category_new($that, $topic);
                 foreach ($this->cat_patterns as $pattern) {
                     try {
                         JxBotNLData::pattern_add($category_id, trim($pattern), $that, $topic);
                     } catch (Exception $err) {
                         // pattern already exists?
                         // ignore, but do a notice
                         $this->notice($err->getMessage());
                     }
                 }
                 foreach ($this->cat_templates as $template) {
                     JxBotNLData::template_add($category_id, $template);
                 }
                 if (count($this->cat_patterns) > 1 || count($this->cat_templates) > 1) {
                     $this->has_multi_pattern_cats = true;
                 }
             }
             break;
         case JxBotAimlImport::STATE_AIML_TOPIC:
             if ($in_name == 'topic') {
                 $this->state = JxBotAimlImport::STATE_AIML;
             }
             break;
         case JxBotAimlImport::STATE_CATEGORY_TOPIC:
             if ($in_name == 'topic') {
                 $this->state = JxBotAimlImport::STATE_CATEGORY;
             }
             break;
         case JxBotAimlImport::STATE_THAT:
             if ($in_name == 'that') {
                 $this->state = JxBotAimlImport::STATE_CATEGORY;
             }
             break;
         case JxBotAimlImport::STATE_PATTERN:
             if ($in_name == 'pattern') {
                 $this->cat_patterns[] = $this->content;
                 $this->state = JxBotAimlImport::STATE_CATEGORY;
             } else {
                 if ($in_name == 'bot' || $in_name == 'set' || $in_name == 'name') {
                     $this->content .= '</' . $in_name . '>';
                 }
             }
             break;
         case JxBotAimlImport::STATE_TEMPLATE:
             if ($in_name == 'template') {
                 $this->cat_templates[] = $this->content;
                 $this->state = JxBotAimlImport::STATE_CATEGORY;
             } else {
                 $this->content .= '</' . $in_name . '>';
             }
             break;
     }
 }