Example #1
0
 public function reset()
 {
     parent::reset('Lines');
     $this->id = null;
     $this->blogid = getBlogId();
     $this->category = 'public';
     $this->root = 'default';
     $this->author = '';
     $this->content = '';
     $this->permalink = '';
     $this->created = null;
     $this->filter = array();
     $this->_error = array();
 }
 static function getParent($id)
 {
     if (!Validator::number($id, 1)) {
         return null;
     }
     $context = Model_Context::getInstance();
     $pool = new DBModel();
     $pool->reset('Categories');
     $blogid = intval($context->getProperty('blog.id'));
     $pool->setQualifier('blogid', 'equals', $blogid);
     $pool->setQualifier('id', 'equals', $id);
     return $pool->getCell('parent');
 }
 function saveSlogan($slogan = null)
 {
     global $database;
     $this->init();
     if (!Validator::number($this->id, 1)) {
         return $this->_error('id');
     }
     if (!Validator::number($this->userid, 1)) {
         return $this->_error('userid');
     }
     if (isset($slogan)) {
         $this->slogan = $slogan;
     }
     $query = new DBModel();
     $query->reset('Entries');
     $query->setQualifier('blogid', $this->blogid);
     if (isset($this->userid)) {
         $query->setQualifier('userid', $this->userid);
     }
     $query->setQualifier('id', $this->id);
     if (!$query->doesExist()) {
         return $this->_error('id');
     }
     if (isset($this->slogan) && $this->validateSlogan($this->slogan)) {
         $slogan0 = $this->slogan;
     } else {
         $slogan0 = $this->slogan = $this->makeSlogan($this->title);
     }
     $slogan0 = Utils_Unicode::lessenAsEncoding($slogan0, 255);
     for ($i = 1; $i < 1000; $i++) {
         //			$checkSlogan = POD::escapeString($this->slogan);
         $checkSlogan = $this->slogan;
         $query->setAttribute('slogan', $checkSlogan, true);
         if (!POD::queryExistence("SELECT id FROM {$database['prefix']}Entries " . "WHERE blogid = " . $this->blogid . " AND id <> {$this->id} AND slogan ='{$checkSlogan}'")) {
             if (!$query->update()) {
                 return $this->_error('update');
             }
             return true;
         }
         $this->slogan = Utils_Unicode::lessenAsEncoding($slogan0, 245) . '-' . $i;
     }
     // if try saveSlogan again, slogan string has more $i
     return $this->_error('limit');
 }