Merge pull request #3727 from monishdeb/CRM-14875
[civicrm-core.git] / CRM / Core / Action.php
index 3e6edc7bfb620366be29264f15acf642866ccaa7..e1de9c1f270556dd337c9f548f832f5265c48a76 100644 (file)
@@ -1,9 +1,9 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.4                                                |
+ | CiviCRM version 4.5                                                |
  +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2013                                |
+ | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
  | This file is a part of CiviCRM.                                    |
  |                                                                    |
@@ -31,7 +31,7 @@
  * and similar across all objects (thus providing both reuse and standards)
  *
  * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2013
+ * @copyright CiviCRM LLC (c) 2004-2014
  * $Id$
  *
  */
@@ -41,7 +41,7 @@ class CRM_Core_Action {
    * Different possible actions are defined here. Keep in sync with the
    * constant from CRM_Core_Form for various modes.
    *
-   * @var const
+   * @var integer const
    *
    * @access public
    */
@@ -114,12 +114,13 @@ class CRM_Core_Action {
    *
    * called by the request object to translate a string into a mask
    *
-   * @param string $action the action to be resolved
+   * @param $str
+   *
+   * @internal param string $action the action to be resolved
    *
    * @return int the action mask corresponding to the input string
    * @access public
    * @static
-   *
    */
   static function resolve($str) {
     $action = 0;
@@ -193,11 +194,15 @@ class CRM_Core_Action {
    * given a set of links and a mask, return the html action string for
    * the links associated with the mask
    *
-   * @param array $links  the set of link items
-   * @param int   $mask   the mask to be used. a null mask means all items
+   * @param array $links the set of link items
+   * @param int $mask the mask to be used. a null mask means all items
    * @param array $values the array of values for parameter substitution in the link items
-   * @param string  $extraULName            enclosed extra links in this UL.
-   * @param boolean $enclosedAllInSingleUL  force to enclosed all links in single UL.
+   * @param string $extraULName enclosed extra links in this UL.
+   * @param boolean $enclosedAllInSingleUL force to enclosed all links in single UL.
+   *
+   * @param null $op
+   * @param null $objectName
+   * @param null $objectId
    *
    * @return string       the html string
    * @access public
@@ -231,8 +236,7 @@ class CRM_Core_Action {
 
     $url = array();
 
-    $firstLink = TRUE;
-    foreach ($seqLinks as $link) {
+    foreach ($seqLinks as $i => $link) {
       if (!$mask || !array_key_exists('bit', $link) || ($mask & $link['bit'])) {
         $extra = isset($link['extra']) ? self::replace($link['extra'], $values) : NULL;
 
@@ -247,46 +251,40 @@ class CRM_Core_Action {
           $urlPath = CRM_Utils_Array::value('url', $link, '#');
         }
 
-        $classes = 'action-item';
-        if ($firstLink) {
-          $firstLink = FALSE;
-          $classes .= " action-item-first";
-        }
+        $classes = 'action-item crm-hover-button';
         if (isset($link['ref'])) {
           $classes .= ' ' . strtolower($link['ref']);
         }
 
         //get the user specified classes in.
         if (isset($link['class'])) {
-          $className = $link['class'];
-          if (is_array($className)) {
-            $className = implode(' ', $className);
-          }
+          $className = is_array($link['class']) ? implode(' ', $link['class']) : $link['class'];
           $classes .= ' ' . strtolower($className);
         }
 
-        $linkClasses = 'class="' . $classes . '"';
-
         if ($urlPath !== '#' && $frontend) {
           $extra .= ' target="_blank"';
         }
-        $url[] = sprintf('<a href="%s" %s title="%s" ' . $extra . '>%s</a>',
+        // Hack to make delete dialogs smaller
+        if (strpos($urlPath, '/delete') || strpos($urlPath, 'action=delete')) {
+          $classes .= " small-popup";
+        }
+        $url[] = sprintf('<a href="%s" class="%s" %s' . $extra . '>%s</a>',
           $urlPath,
-          $linkClasses,
-          CRM_Utils_Array::value('title', $link),
+          $classes,
+          !empty($link['title']) ? "title='{$link['title']}' " : '',
           $link['name']
         );
       }
     }
 
 
-    $result = '';
     $mainLinks = $url;
     if ($enclosedAllInSingleUL) {
       $allLinks = '';
       CRM_Utils_String::append($allLinks, '</li><li>', $mainLinks);
       $allLinks = "{$extraULName}<ul class='panel'><li>{$allLinks}</li></ul>";
-      $result = "<span class='btn-slide'>{$allLinks}</span>";
+      $result = "<span class='btn-slide crm-hover-button'>{$allLinks}</span>";
     }
     else {
       $extra = '';
@@ -299,7 +297,7 @@ class CRM_Core_Action {
       $resultLinks = '';
       CRM_Utils_String::append($resultLinks, '', $mainLinks);
       if ($extra) {
-        $result = "<span>{$resultLinks}</span><span class='btn-slide'>{$extra}</span>";
+        $result = "<span>{$resultLinks}</span><span class='btn-slide crm-hover-button'>{$extra}</span>";
       }
       else {
         $result = "<span>{$resultLinks}</span>";