Icon cleanup
[civicrm-core.git] / CRM / Core / BAO / Navigation.php
index 1be9ede08bfc8ec531e62643c83769598fdf831f..ec1b4ddefada470dfc9b3053a745cd8fc913c064 100644 (file)
@@ -23,7 +23,7 @@
  | GNU Affero General Public License or the licensing of CiviCRM,     |
  | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
  +--------------------------------------------------------------------+
-*/
+ */
 
 /**
  *
@@ -38,23 +38,23 @@ class CRM_Core_BAO_Navigation extends CRM_Core_DAO_Navigation {
   const CACHE_KEY_STRLEN = 8;
 
   /**
-   * Class constructor
+   * Class constructor.
    */
   public function __construct() {
     parent::__construct();
   }
 
   /**
-   * Update the is_active flag in the db
+   * Update the is_active flag in the db.
    *
    * @param int $id
    *   Id of the database record.
    * @param bool $is_active
    *   Value we want to set the is_active field.
    *
-   * @return Object             DAO object on sucess, NULL otherwise
+   * @return Object
+   *   DAO object on sucess, NULL otherwise
    *
-   * @static
    */
   public static function setIsActive($id, $is_active) {
     return CRM_Core_DAO::setFieldValue('CRM_Core_DAO_Navigation', $id, 'is_active', $is_active);
@@ -63,8 +63,8 @@ class CRM_Core_BAO_Navigation extends CRM_Core_DAO_Navigation {
   /**
    * Get existing / build navigation for CiviCRM Admin Menu
    *
-   * @static
-   * @return array associated array
+   * @return array
+   *   associated array
    */
   public static function getMenus() {
     $menus = array();
@@ -84,10 +84,10 @@ class CRM_Core_BAO_Navigation extends CRM_Core_DAO_Navigation {
   /**
    * Add/update navigation record
    *
-   * @param array associated array of submitted values
+   * @param $params associated array of submitted values
    *
-   * @return object navigation object
-   * @static
+   * @return object
+   *   navigation object
    */
   public static function add(&$params) {
     $navigation = new CRM_Core_DAO_Navigation();
@@ -123,15 +123,15 @@ class CRM_Core_BAO_Navigation extends CRM_Core_DAO_Navigation {
   }
 
   /**
-   * Fetch object based on array of properties
+   * Fetch object based on array of properties.
    *
    * @param array $params
    *   (reference ) an assoc array of name/value pairs.
    * @param array $defaults
    *   (reference ) an assoc array to hold the flattened values.
    *
-   * @return CRM_Core_BAO_Navigation object on success, NULL otherwise
-   * @static
+   * @return CRM_Core_BAO_Navigation|null
+   *   object on success, NULL otherwise
    */
   public static function retrieve(&$params, &$defaults) {
     $navigation = new CRM_Core_DAO_Navigation();
@@ -147,14 +147,15 @@ class CRM_Core_BAO_Navigation extends CRM_Core_DAO_Navigation {
   }
 
   /**
-   * Calculate navigation weight
+   * Calculate navigation weight.
    *
    * @param int $parentID
    *   Parent_id of a menu.
    * @param int $menuID
    *   Menu id.
    *
-   * @return int $weight string@static
+   * @return int
+   *   $weight string
    */
   public static function calculateWeight($parentID = NULL, $menuID = NULL) {
     $domainID = CRM_Core_Config::domainID();
@@ -176,10 +177,10 @@ class CRM_Core_BAO_Navigation extends CRM_Core_DAO_Navigation {
   }
 
   /**
-   * Get formatted menu list
+   * Get formatted menu list.
    *
-   * @return array $navigations returns associated array
-   * @static
+   * @return array
+   *   returns associated array
    */
   public static function getNavigationList() {
     $cacheKeyString = "navigationList";
@@ -262,7 +263,7 @@ FROM civicrm_navigation WHERE domain_id = $domainID {$whereClause} ORDER BY pare
   }
 
   /**
-   * Build navigation tree
+   * Build navigation tree.
    *
    * @param array $navigationTree
    *   Nested array of menus.
@@ -271,8 +272,8 @@ FROM civicrm_navigation WHERE domain_id = $domainID {$whereClause} ORDER BY pare
    * @param bool $navigationMenu
    *   True when called for building top navigation menu.
    *
-   * @return array $navigationTree nested array of menus
-   * @static
+   * @return array
+   *   nested array of menus
    */
   public static function buildNavigationTree(&$navigationTree, $parentID, $navigationMenu = TRUE) {
     $whereClause = " parent_id IS NULL";
@@ -301,7 +302,8 @@ ORDER BY parent_id, weight";
 
       // for each menu get their children
       $navigationTree[$navigation->id] = array(
-        'attributes' => array('label' => $label,
+        'attributes' => array(
+          'label' => $label,
           'name' => $navigation->name,
           'url' => $navigation->url,
           'permission' => $navigation->permission,
@@ -310,7 +312,8 @@ ORDER BY parent_id, weight";
           'parentID' => $navigation->parent_id,
           'navID' => $navigation->id,
           'active' => $navigation->is_active,
-        ));
+        ),
+      );
       self::buildNavigationTree($navigationTree[$navigation->id]['child'], $navigation->id, $navigationMenu);
     }
 
@@ -318,15 +321,15 @@ ORDER BY parent_id, weight";
   }
 
   /**
-   * Build menu
+   * Build menu.
    *
    * @param bool $json
    *   By default output is html.
    * @param bool $navigationMenu
    *   True when called for building top navigation menu.
    *
-   * @return returns html or json object
-   * @static
+   * @return string
+   *   html or json string
    */
   public static function buildNavigation($json = FALSE, $navigationMenu = TRUE) {
     $navigations = array();
@@ -384,7 +387,7 @@ ORDER BY parent_id, weight";
   }
 
   /**
-   * Recursively check child menus
+   * Recursively check child menus.
    *
    * @param array $value
    * @param string $navigationString
@@ -461,7 +464,7 @@ ORDER BY parent_id, weight";
   }
 
   /**
-   * Get Menu name
+   * Get Menu name.
    *
    * @param $value
    * @param array $skipMenuItems
@@ -472,15 +475,15 @@ ORDER BY parent_id, weight";
     // want to use ts() as it would throw the ts-extractor off
     $i18n = CRM_Core_I18n::singleton();
 
-    $name       = $i18n->crm_translate($value['attributes']['label'], array('context' => 'menu'));
-    $url        = $value['attributes']['url'];
+    $name = $i18n->crm_translate($value['attributes']['label'], array('context' => 'menu'));
+    $url = $value['attributes']['url'];
     $permission = $value['attributes']['permission'];
-    $operator   = $value['attributes']['operator'];
-    $parentID   = $value['attributes']['parentID'];
-    $navID      = $value['attributes']['navID'];
-    $active     = $value['attributes']['active'];
-    $menuName   = $value['attributes']['name'];
-    $target     = CRM_Utils_Array::value('target', $value['attributes']);
+    $operator = $value['attributes']['operator'];
+    $parentID = $value['attributes']['parentID'];
+    $navID = $value['attributes']['navID'];
+    $active = $value['attributes']['active'];
+    $menuName = $value['attributes']['name'];
+    $target = CRM_Utils_Array::value('target', $value['attributes']);
 
     if (in_array($parentID, $skipMenuItems) || !$active) {
       $skipMenuItems[] = $navID;
@@ -489,7 +492,9 @@ ORDER BY parent_id, weight";
 
     //we need to check core view/edit or supported acls.
     if (in_array($menuName, array(
-      'Search...', 'Contacts'))) {
+      'Search...',
+      'Contacts',
+    ))) {
       if (!CRM_Core_Permission::giveMeAllACLs()) {
         $skipMenuItems[] = $navID;
         return FALSE;
@@ -573,13 +578,13 @@ ORDER BY parent_id, weight";
   }
 
   /**
-   * Create navigation for CiviCRM Admin Menu
+   * Create navigation for CiviCRM Admin Menu.
    *
    * @param int $contactID
    *   Contact id.
    *
-   * @return string $navigation returns navigation html
-   * @static
+   * @return string
+   *   returns navigation html
    */
   public static function createNavigation($contactID) {
     $config = CRM_Core_Config::singleton();
@@ -594,7 +599,7 @@ ORDER BY parent_id, weight";
       // get home menu from db
       $homeParams = array('name' => 'Home');
       $homeNav = array();
-      $homeIcon = '<img src="' . $config->userFrameworkResourceURL . 'i/logo16px.png" style="vertical-align:middle;" />';
+      $homeIcon = '<span class="crm-logo-sm" ></span>';
       self::retrieve($homeParams, $homeNav);
       if ($homeNav) {
         list($path, $q) = explode('?', $homeNav['url']);
@@ -638,7 +643,7 @@ ORDER BY parent_id, weight";
   }
 
   /**
-   * Reset navigation for all contacts or a specified contact
+   * Reset navigation for all contacts or a specified contact.
    *
    * @param int $contactID
    *   Reset only entries belonging to that contact ID.
@@ -675,20 +680,19 @@ ORDER BY parent_id, weight";
   }
 
   /**
-   * Process navigation
+   * Process navigation.
    *
    * @param array $params
    *   Associated array, $_GET.
    *
    * @return void
-   * @static
    */
   public static function processNavigation(&$params) {
-    $nodeID      = (int)str_replace("node_", "", $params['id']);
-    $referenceID = (int)str_replace("node_", "", $params['ref_id']);
-    $position    = $params['ps'];
-    $type        = $params['type'];
-    $label       = CRM_Utils_Array::value('data', $params);
+    $nodeID = (int) str_replace("node_", "", $params['id']);
+    $referenceID = (int) str_replace("node_", "", $params['ref_id']);
+    $position = $params['ps'];
+    $type = $params['type'];
+    $label = CRM_Utils_Array::value('data', $params);
 
     switch ($type) {
       case "move":
@@ -710,7 +714,7 @@ ORDER BY parent_id, weight";
   }
 
   /**
-   * Process move action
+   * Process move action.
    *
    * @param $nodeID
    *   Node that is being moved.
@@ -720,7 +724,6 @@ ORDER BY parent_id, weight";
    *   New position of the nod, it starts with 0 - n.
    *
    * @return void
-   * @static
    */
   public static function processMove($nodeID, $referenceID, $position) {
     // based on the new position we need to get the weight of the node after moved node
@@ -740,14 +743,14 @@ ORDER BY parent_id, weight";
     }
 
     $incrementOtherNodes = TRUE;
-    $sql    = "SELECT weight from civicrm_navigation WHERE {$parentClause} ORDER BY weight LIMIT %1, 1";
+    $sql = "SELECT weight from civicrm_navigation WHERE {$parentClause} ORDER BY weight LIMIT %1, 1";
     $params = array(1 => array($position, 'Positive'));
     $newWeight = CRM_Core_DAO::singleValueQuery($sql, $params);
 
     // this means node is moved to last position, so you need to get the weight of last element + 1
     if (!$newWeight) {
       $lastPosition = $position - 1;
-      $sql    = "SELECT weight from civicrm_navigation WHERE {$parentClause} ORDER BY weight LIMIT %1, 1";
+      $sql = "SELECT weight from civicrm_navigation WHERE {$parentClause} ORDER BY weight LIMIT %1, 1";
       $params = array(1 => array($lastPosition, 'Positive'));
       $newWeight = CRM_Core_DAO::singleValueQuery($sql, $params);
 
@@ -776,7 +779,7 @@ ORDER BY parent_id, weight";
   }
 
   /**
-   *  Function to process rename action for tree
+   *  Function to process rename action for tree.
    *
    * @param int $nodeID
    * @param $label
@@ -786,7 +789,7 @@ ORDER BY parent_id, weight";
   }
 
   /**
-   * Process delete action for tree
+   * Process delete action for tree.
    *
    * @param int $nodeID
    */
@@ -796,18 +799,18 @@ ORDER BY parent_id, weight";
   }
 
   /**
-   * Get the info on navigation item
+   * Get the info on navigation item.
    *
    * @param int $navigationID
    *   Navigation id.
    *
-   * @return array associated array
-   * @static
+   * @return array
+   *   associated array
    */
   public static function getNavigationInfo($navigationID) {
-    $query  = "SELECT parent_id, weight FROM civicrm_navigation WHERE id = %1";
+    $query = "SELECT parent_id, weight FROM civicrm_navigation WHERE id = %1";
     $params = array($navigationID, 'Integer');
-    $dao    = CRM_Core_DAO::executeQuery($query, array(1 => $params));
+    $dao = CRM_Core_DAO::executeQuery($query, array(1 => $params));
     $dao->fetch();
     return array(
       'parent_id' => $dao->parent_id,
@@ -816,12 +819,11 @@ ORDER BY parent_id, weight";
   }
 
   /**
-   * Update menu
+   * Update menu.
    *
    * @param array $params
    * @param array $newParams
    *   New value of params.
-   * @static
    */
   public static function processUpdate($params, $newParams) {
     $dao = new CRM_Core_DAO_Navigation();
@@ -850,4 +852,5 @@ ORDER BY parent_id, weight";
     }
     return $key;
   }
+
 }