/**
  * Return manager instance
  *
  * @access protected
  * @param void
  * @return CustomPropertiesByCoType 
  */
 function manager()
 {
     if (!$this->manager instanceof CustomPropertiesByCoType) {
         $this->manager = CustomPropertiesByCoType::instance();
     }
     return $this->manager;
 }
 function get_custom_properties()
 {
     $object_type = array_var($_GET, 'object_type', '');
     if ($object_type != '') {
         $cp = CustomProperties::getAllCustomPropertiesByObjectType($object_type);
         $customProperties = array();
         foreach ($cp as $custom) {
             $prop = array();
             $prop['id'] = $custom->getId();
             $prop['name'] = $custom->getName();
             $prop['object_type'] = $custom->getObjectType();
             $prop['description'] = $custom->getDescription();
             $prop['type'] = $custom->getType();
             $prop['values'] = $custom->getValues();
             $prop['default_value'] = $custom->getDefaultValue();
             $prop['required'] = $custom->getIsRequired();
             $prop['multiple_values'] = $custom->getIsMultipleValues();
             $prop['visible_by_default'] = $custom->getVisibleByDefault();
             $prop['co_types'] = CustomPropertiesByCoType::instance()->getCoTypesIdsForCpCSV($custom->getId());
             $customProperties[] = $prop;
         }
         ajx_current("empty");
         ajx_extra_data(array("custom_properties" => $customProperties));
     }
 }
 /**
  * Return all custom properties that an object type has
  *
  * @param $object_type
  * @return array
  * 
  */
 static function getAllCustomPropertiesByObjectType($object_type, $co_type = null)
 {
     if ($co_type) {
         $cond = array("`object_type_id` = ? AND `id` IN (?)", $object_type, CustomPropertiesByCoType::instance()->getCustomPropertyIdsByCoTypeCSV($co_type));
     } else {
         $cond = array("`object_type_id` = ?", $object_type);
     }
     return self::findAll(array('conditions' => $cond, 'order' => 'property_order asc'));
 }
 /**
 * This function will return paginated result. Result is an array where first element is 
 * array of returned object and second populated pagination object that can be used for 
 * obtaining and rendering pagination data using various helpers.
 * 
 * Items and pagination array vars are indexed with 0 for items and 1 for pagination
 * because you can't use associative indexing with list() construct
 *
 * @access public
 * @param array $arguments Query argumens (@see find()) Limit and offset are ignored!
 * @param integer $items_per_page Number of items per page
 * @param integer $current_page Current page number
 * @return array
 */
 function paginate($arguments = null, $items_per_page = 10, $current_page = 1) {
   if(isset($this) && instance_of($this, 'CustomPropertiesByCoType')) {
     return parent::paginate($arguments, $items_per_page, $current_page);
   } else {
     return  CustomPropertiesByCoType::instance()->paginate($arguments, $items_per_page, $current_page);
   } // if
 } // paginate