CRM-14478 - CRM_Core_EntityReference - Move SQL construction

This anticipates polymorphic SQL construction -- where have different
classes for different types of references (eg conventional SQL FKs; dynamic
FK; option-value FKs) and where each class constructs slightly different
SQL.
CRM-14478 - Split CRM_Core_EntityReference into different classes
CRM-14478 - Add CRM_Core_Reference_OptionValue
CRM_Utils_Array::index() -- Allow indexing when some keys are NULL/undefined
CRM-14478 - Add CRM_Core_DAO::getReferenceCounts()
CRM-14478 - Add generic API, "getrefcount"
CRM-14478 - CRM_Case_XMLRepository - Add getActivityReferenceCount(), getRelationshipReferenceCount()
CRM-14478 - Allow components and hooks to influence refcounts
CRM-14478 - Count references to activity-types and relationship-types in CiviCase XML
Merge pull request #3322 from totten/master-refcount

CRM-14478 - Add generic API, "getrefcount"
comment fixes
remove duplicate assignments
add missing comments - tests directory
CRM/Utils add comments
Merge pull request #3344 from eileenmcnaughton/comments

Comments
CRM/Contact add comment blocks
CRM/Upgrade add missing comment blocks
CRM/SMS add missing comment blocks
CRM/Report add missing comment blocks
Merge pull request #3345 from eileenmcnaughton/comments

Add automated comment blocks for functions missing them