protected function CALCFIELDS($flowfield_name) { $config = static::getFieldsConfig(); if (isset($config[$flowfield_name]) && $flowfield_name == '_meta_value_preview') { if ($this->overwrite == true || $this->meta_name != static::$META_NAME_TITLE) { return $this->meta_value; } else { $trs = QdTRootSetup::GET(); if ($this->seo_tpl == 1) { return str_replace('{prefix}', $this->meta_value, $trs->seo_title_struct); } else { return str_replace('{prefix}', $this->meta_value, $trs->seo_title_struct_2); } } } return parent::CALCFIELDS($flowfield_name); }
public function delete($location = '', $validate = true) { if ($validate && $this->type === static::$TYPE_UNUSED) { //get id $id = $this->getMediaID('path'); //delete wp media too if ($id != null) { wp_delete_attachment($id, true); } } return parent::delete($location, $validate); }
public function __get($field_name) { //check cached value if (is_array($this->qd_cached_attr) && isset($this->qd_cached_attr[$field_name])) { return $this->qd_cached_attr[$field_name]; } //calculate field value if (static::ISFLOWFIELD($field_name)) { //CALC FlowField First return $this->CALCFIELDS($field_name); } else { if (static::ISSYSTEMFIELD($field_name)) { $class_name = $this->getCalledClassName(); //system preserved field if ($field_name == '__sys_note_url') { $tmp = $this->qd_cached_attr[$field_name] = Qdmvc_Helper::getCompactPageListLink('note', array('model' => $class_name, 'model_id' => $this->id)); //COUNT $record = new QdNote(); $record->SETRANGE('model', $this->getCalledClassName()); $record->SETRANGE('model_id', $this->id); $count = $record->COUNTLIST(); return add_query_arg(array('item_count' => $count), $tmp); } else { if ($field_name == '__sys_log_url') { $tmp = $this->qd_cached_attr[$field_name] = Qdmvc_Helper::getCompactPageListLink('log', array('model' => $class_name, 'model_id' => $this->id)); //COUNT $record = new QdLog(); $record->SETRANGE('model', $this->getCalledClassName()); $record->SETRANGE('model_id', $this->id); $count = $record->COUNTLIST(); return add_query_arg(array('item_count' => $count), $tmp); } else { if ($field_name == '__sys_image_url') { $tmp = $this->qd_cached_attr[$field_name] = Qdmvc_Helper::getCompactPageListLink('image', array('model' => $class_name, 'model_id' => $this->id)); //COUNT $record = new QdImage(); $record->SETRANGE('model', $this->getCalledClassName()); $record->SETRANGE('model_id', $this->id); $count = $record->COUNTLIST(); return add_query_arg(array('item_count' => $count), $tmp); } else { if ($field_name == '__lasteditor_name') { if ($this->lasteditor_id > 0) { $user_info = get_userdata($this->lasteditor_id); return $this->qd_cached_attr[$field_name] = $user_info->user_login; } return Qdmvc_Helper::getNoneText(); } else { if ($field_name == '__owner_name') { if ($this->owner_id > 0) { $user_info = get_userdata($this->owner_id); return $this->qd_cached_attr[$field_name] = $user_info->user_login; } return Qdmvc_Helper::getNoneText(); } else { if ($field_name == 'date_created' || $field_name == 'date_modified' || $field_name == 'owner_id') { return parent::__get($field_name); } else { // if ($field_name == '__sys_lines_url') {//Default system Lines Field return $this->getLinesURL($field_name); } } } } } } } } return parent::__get($field_name); }
public static function getFieldsConfig() { return array_merge(parent::getFieldsConfig(), array('action' => array('Caption' => array('en-US' => 'Action', 'vi-VN' => 'Hành động'), 'DataType' => 'Option', 'Options' => array(static::$ACTION_UNDEFINED => array('Caption' => array('en-US' => 'Undefined', 'vi-VN' => 'Không xác định')), static::$ACTION_INSERT => array('Caption' => array('en-US' => 'Insert', 'vi-VN' => 'Thêm mới')), static::$ACTION_MODIFY => array('Caption' => array('en-US' => 'Modify', 'vi-VN' => 'Sửa')), static::$ACTION_DELETE => array('Caption' => array('en-US' => 'Delete', 'vi-VN' => 'Xóa'))), 'ReadOnly' => true), 'location' => array('Caption' => array('en-US' => 'Location', 'vi-VN' => 'Nơi phát sinh'), 'ReadOnly' => true), 'ip' => array('Caption' => array('en-US' => 'IP', 'vi-VN' => 'IP'), 'ReadOnly' => true))); }