Merge pull request #999 from lcdservices/master
[civicrm-core.git] / CRM / Utils / String.php
index abafc42cf28fd05fbc17609482553bdd35772c6d..1e8cde11a977fe4e3c8ffaaffb2b4b02355eae4a 100644 (file)
@@ -488,11 +488,7 @@ class CRM_Utils_String {
    */
   static function addJqueryFiles(&$html) {
     CRM_Core_Resources::singleton()->addCoreResources('html-header');
-    if (!defined('CIVICRM_UF_HEAD')) {
-      return CRM_Core_Region::instance('html-header')->render('', FALSE) . $html;
-    } else {
-      return $html;
-    }
+    return CRM_Core_Region::instance('html-header')->render('', FALSE) . $html;
   }
 
   /**
@@ -635,5 +631,24 @@ class CRM_Utils_String {
     return $result;
   }
 
+  /**
+   * Examples:
+   * "admin foo" => array(NULL,"admin foo")
+   * "cms:admin foo" => array("cms", "admin foo")
+   *
+   * @param string $string e.g. "view all contacts". Syntax: "[prefix:]name"
+   * @return array (0 => string|NULL $prefix, 1 => string $value)
+   */
+  public static function parsePrefix($delim, $string, $defaultPrefix = NULL) {
+    $pos = strpos($string, $delim);
+    if ($pos === FALSE) {
+      return array($defaultPrefix, $string);
+    }
+    else {
+      return array(substr($string, 0, $pos), substr($string, 1+$pos));
+    }
+  }
+
+
 }