示例#1
0
 /**
  * Create new empty item in DB
  * @param int    $appId
  * @param string $type
  * @param string $nameSuf
  * @return Item
  */
 public function createEmpty($appId, $type, $nameSuf = null)
 {
     // some vars
     $now = $this->app->date->create()->toSQL();
     $userId = $this->app->user->get()->get('id');
     // create empty item
     $item = $this->app->object->create('Item');
     // set default data
     $item->application_id = (int) $appId;
     $item->type = $type;
     $item->state = 0;
     $item->access = $this->app->joomla->getDefaultAccess();
     $item->modified_by = $userId;
     $item->created_by = $userId;
     $item->created = $now;
     $item->modified = $now;
     $item->publish_up = $now;
     $item->name = JText::_('JBZOO_NEW_ITEM_NAME') . ($nameSuf ? ' #' . $nameSuf : '');
     $item->alias = uniqid('item-uid-');
     // hack for speed
     // set default params
     $item->getParams()->loadArray(array("metadata.title" => "", "metadata.description" => "", "metadata.keywords" => "", "metadata.robots" => "", "metadata.author" => "", "config.enable_comments" => 1, "config.primary_category" => "", "jbzoo.no_index" => 1));
     // for create item_id in new Item object
     $this->_table->save($item);
     return $item;
 }