/**
  * Load a module from the database
  *
  * @param int $id ID of the module
  *
  * @return XoopsModule|bool on fail
  */
 public function getById($id = null)
 {
     $id = (int) $id;
     if ($id > 0) {
         if (!empty($this->cachedModulesByMid[$id])) {
             return $this->cachedModulesByMid[$id];
         } else {
             $module = parent::get($id);
             if (!is_object($module)) {
                 return false;
             }
             $this->cachedModulesByMid[$id] = $module;
             $this->cachedModulesByDirname[$module->getVar('dirname')] = $module;
             return $module;
         }
     }
     return false;
 }
Beispiel #2
0
 public function getClone($content_id)
 {
     $values = parent::get($content_id)->toArray();
     $values['content_id'] = 0;
     $values['content_title'] = PageLocale::CONTENT_COPY . $values['content_title'];
     $values['content_weight'] = 0;
     $values['content_hits'] = 0;
     $values['content_votes'] = 0;
     $values['content_rating'] = 0;
     $values['content_create'] = time();
     $obj = parent::create();
     $obj->setVars($values);
     return $obj;
 }
Beispiel #3
0
 /**
  * @param null $id
  * @param null $fields
  *
  * @return null|PublisherCategory
  */
 public function get($id = null, $fields = null)
 {
     static $cats;
     if ($fields == null && isset($cats[$id])) {
         return $cats[$id];
     }
     $obj = parent::get($id, $fields);
     if ($fields == null) {
         $cats[$id] = $obj;
     }
     return $obj;
 }
Beispiel #4
0
 /**
  * Get a {@link ProfileProfile}
  *
  * @param      $uid
  * @param bool $createOnFailure create a new {@link ProfileProfile} if none is fetched
  *
  * @return null|ProfileProfile|XoopsObject
  */
 public function getProfile($uid, $createOnFailure = true)
 {
     $obj = parent::get($uid);
     if (!is_object($obj) && $createOnFailure) {
         $obj = $this->create();
     }
     return $obj;
 }