public static function retrieveByPKs($pks, $con = null) { if ($con === null) { $con = Propel::getConnection(self::DATABASE_NAME); } $objs = null; if (empty($pks)) { $objs = array(); } else { $criteria = new Criteria(); $criteria->add(WebItemCategoryPeer::ID, $pks, Criteria::IN); $objs = WebItemCategoryPeer::doSelect($criteria, $con); } return $objs; }
public function save($param) { $department_id = $param['department_id']; $departmentAvailable = $this->tools->departmentAvailable($department_id); $item = new WebItem(); if (empty($param['section'])) { $this->jsonwrapper->show_json_error('section', 'Kolom section harap diisi.'); } $itemSection = DepartmentPeer::retrieveByPK($param['section']); if (!$itemSection) { $this->jsonwrapper->show_json_error('type', 'Section yang anda masukkan tidak ditemukan.'); } if (!in_array($param['section'], $departmentAvailable)) { $this->jsonwrapper->show_json_error('forbidden', 'Maaf, anda tidak dapat membuat news dalam section ini.'); } if (empty($param['category_id'])) { $this->jsonwrapper->show_json_error('category', 'Kolom category harap diisi.'); } $itemCategory = WebItemCategoryPeer::retrieveByPK($param['category_id']); if (!$itemCategory) { $this->jsonwrapper->show_json_error('category', 'News Category yang anda masukkan tidak ditemukan.'); } if (empty($param['date'])) { $this->jsonwrapper->show_json_error('date', 'Kolom created harap diisi.'); } if (empty($param['hour'])) { $param['hour'] = 0; } if (empty($param['minute'])) { $param['minute'] = 0; } $newDate = $param['date'] . ' ' . $param['hour'] . ':' . $param['minute'] . ':00'; $newDate = date('Y-m-d H:i:s', strtotime($newDate)); if (empty($param['title'])) { $this->jsonwrapper->show_json_error('title', 'Kolom title harap diisi.'); } if (empty($param['initial'])) { $this->jsonwrapper->show_json_error('initial', 'Kolom initial harap diisi.'); } if (empty($param['image'])) { /* $this->jsonwrapper->show_json_error('image', 'Kolom image harap diisi.'); */ $param['image'] = ''; } if (empty($param['description'])) { $this->jsonwrapper->show_json_error('description', 'Kolom description harap diisi.'); } if (!empty($param['id'])) { $item = WebItemPeer::retrieveByPK($param['id']); if (!$item) { $this->jsonwrapper->show_json_error('id', 'News tidak ditemukan.'); } if (!in_array($item->getDepartmentId(), $departmentAvailable)) { $this->jsonwrapper->show_json_error('forbidden', 'Maaf, anda tidak dapat mengedit news ini.'); } } else { $item->setPublished(0); $item->setCreated(date('Y-m-d H:i:s')); } /* Add */ $item->setTitle($param['title']); $item->setInitial($param['initial']); $item->setImage($param['image']); $item->setDepartmentId($param['section']); $item->setItemCategoryId($param['category_id']); $item->setDescription($param['description']); $item->setCreated($newDate); if (!$item->validate()) { var_dump($item->validate()); } $item->save(); $output = array('success' => 1, 'data' => $param); $this->jsonwrapper->print_json($output); }
public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME) { $keys = WebItemCategoryPeer::getFieldNames($keyType); if (array_key_exists($keys[0], $arr)) { $this->setId($arr[$keys[0]]); } if (array_key_exists($keys[1], $arr)) { $this->setParentId($arr[$keys[1]]); } if (array_key_exists($keys[2], $arr)) { $this->setInitial($arr[$keys[2]]); } if (array_key_exists($keys[3], $arr)) { $this->setDepartmentId($arr[$keys[3]]); } if (array_key_exists($keys[4], $arr)) { $this->setName($arr[$keys[4]]); } if (array_key_exists($keys[5], $arr)) { $this->setDescription($arr[$keys[5]]); } if (array_key_exists($keys[6], $arr)) { $this->setCreated($arr[$keys[6]]); } if (array_key_exists($keys[7], $arr)) { $this->setPublished($arr[$keys[7]]); } }
public static function doSelectJoinAllExceptDepartment(Criteria $c, $con = null) { $c = clone $c; if ($c->getDbName() == Propel::getDefaultDB()) { $c->setDbName(self::DATABASE_NAME); } WebItemPeer::addSelectColumns($c); $startcol2 = WebItemPeer::NUM_COLUMNS - WebItemPeer::NUM_LAZY_LOAD_COLUMNS + 1; WebItemCategoryPeer::addSelectColumns($c); $startcol3 = $startcol2 + WebItemCategoryPeer::NUM_COLUMNS; $c->addJoin(WebItemPeer::ITEM_CATEGORY_ID, WebItemCategoryPeer::ID); $rs = BasePeer::doSelect($c, $con); $results = array(); while ($rs->next()) { $omClass = WebItemPeer::getOMClass(); $cls = Propel::import($omClass); $obj1 = new $cls(); $obj1->hydrate($rs); $omClass = WebItemCategoryPeer::getOMClass(); $cls = Propel::import($omClass); $obj2 = new $cls(); $obj2->hydrate($rs, $startcol2); $newObject = true; for ($j = 0, $resCount = count($results); $j < $resCount; $j++) { $temp_obj1 = $results[$j]; $temp_obj2 = $temp_obj1->getWebItemCategory(); if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) { $newObject = false; $temp_obj2->addWebItem($obj1); break; } } if ($newObject) { $obj2->initWebItems(); $obj2->addWebItem($obj1); } $results[] = $obj1; } return $results; }
public function getWebItemCategory($con = null) { include_once 'lib/model/om/BaseWebItemCategoryPeer.php'; if ($this->aWebItemCategory === null && $this->item_category_id !== null) { $this->aWebItemCategory = WebItemCategoryPeer::retrieveByPK($this->item_category_id, $con); } return $this->aWebItemCategory; }
public function publish($param) { $category = WebItemCategoryPeer::retrieveByPK($param['id']); if (!$category) { $this->showJsonError('category', 'Category tidak ditemukan.'); } if ($category->getPublished() == 1) { $category->setPublished(0); } else { $category->setPublished(1); } $category->save(); $output = array('success' => 1, 'message' => 'Success', 'data' => $category->toArray()); $this->jsonwrapper->print_json($output); }