Ejemplo n.º 1
0
 /**
  * Set param value
  *
  * By default, all values will be considered strings
  *
  * @todo extra_cat_IDs recording
  *
  * @param string parameter name
  * @param mixed parameter value
  * @param boolean true to set to NULL if empty value
  * @return boolean true, if a value has been set; false if it has not changed
  */
 function set($parname, $parvalue, $make_null = false)
 {
     switch ($parname) {
         case 'pst_ID':
         case 'priority':
             return $this->set_param($parname, 'number', $parvalue, true);
         case 'content':
             $r1 = $this->set_param('content', 'string', $parvalue, $make_null);
             // Update wordcount as well:
             $r2 = $this->set_param('wordcount', 'number', bpost_count_words($this->content), false);
             return $r1 || $r2;
             // return true if one changed
         // return true if one changed
         case 'wordcount':
         case 'featured':
             return $this->set_param($parname, 'number', $parvalue, false);
         case 'datedeadline':
             return $this->set_param('datedeadline', 'date', $parvalue, true);
         case 'order':
             return $this->set_param('order', 'number', $parvalue, true);
         case 'renderers':
             // deprecated
             return $this->set_renderers($parvalue);
         case 'excerpt':
             if ($this->excerpt_autogenerated) {
                 // Check if the excerpt needs to keep getting autogenerated...
                 $autovalue = $this->get_autogenerated_excerpt();
                 $post_excerpt_previous_md5 = param('post_excerpt_previous_md5', 'string');
                 // TODO: this is itemform specific and should not be like that.
                 if ($post_excerpt_previous_md5 == md5($parvalue) || empty($post_excerpt_previous_md5)) {
                     // old value has not changed, it keeps getting autogenerated:
                     $parvalue = $autovalue;
                 }
             }
             if (parent::set('excerpt', $parvalue, $make_null)) {
                 // mark excerpt as not being autogenerated anymore, if user has changed it from the autogenerated value.
                 if (isset($autovalue) && $parvalue != $autovalue) {
                     $this->set('excerpt_autogenerated', 0);
                 }
             }
             break;
         default:
             return parent::set($parname, $parvalue, $make_null);
     }
 }
Ejemplo n.º 2
0
 /**
  * Set param value
  *
  * By default, all values will be considered strings
  *
  * @todo extra_cat_IDs recording
  *
  * @param string parameter name
  * @param mixed parameter value
  * @param boolean true to set to NULL if empty value
  * @return boolean true, if a value has been set; false if it has not changed
  */
 function set($parname, $parvalue, $make_null = false)
 {
     switch ($parname) {
         case 'pst_ID':
             return $this->set_param($parname, 'number', $parvalue, true);
         case 'content':
             $r1 = $this->set_param('content', 'string', $parvalue, $make_null);
             // Update wordcount as well:
             $r2 = $this->set_param('wordcount', 'number', bpost_count_words($this->content), false);
             return $r1 || $r2;
             // return true if one changed
         // return true if one changed
         case 'wordcount':
             return $this->set_param('wordcount', 'number', $parvalue, false);
         case 'datedeadline':
             return $this->set_param('datedeadline', 'date', $parvalue, true);
         case 'renderers':
             // deprecated
             return $this->set_renderers($parvalue);
         default:
             return parent::set($parname, $parvalue, $make_null);
     }
 }