Example #1
0
 function create_item($data, $parent = null)
 {
     if ($parent) {
         $data['pid'] = $parent->id;
     }
     $id = $this->collection->create($data);
     return $this->collection->get_item_by_id($id);
 }
Example #2
0
 /**
  * @param array $data initial
  * @param mixed $parent
  * @return node_collection
  */
 function create($data, $isDir = false)
 {
     $data['pid'] = @$data['pid'] ?: $this->node_id;
     $data['owner_uid'] = 1;
     $data['active'] = 1;
     $data['site_id'] = $this->site_id;
     $data['title'] = $this->iconv(@$data['title']);
     $data['text'] = htmlspecialchars($this->iconv(@$data['text']), ENT_COMPAT, 'UTF-8');
     $data['description'] = htmlspecialchars($this->iconv(@$data['description']), ENT_COMPAT, 'UTF-8');
     $this->counter++;
     // skip
     if ($this->limit && $this->counter > $this->limit) {
         return false;
     }
     if ($this->dry_run) {
         $result = $this->counter;
     } else {
         $result = $this->collection->create($data);
     }
     core::dprint(array('created: %-4d|%-4d|%s%s', $data['pid'], $result, $isDir ? '*' : '', $data['title']), core::E_MESSAGE);
     return $result;
 }