Пример #1
0
 /**
  * Get icon for repository item.
  *
  * @param	int			object id
  * @param	string		size (big, small, tiny)
  * @param	string		object type
  * @param	boolean		true: offline, false: online
  */
 public static function _getIcon($a_obj_id = "", $a_size = "big", $a_type = "", $a_offline = false)
 {
     global $ilSetting, $objDefinition;
     if ($a_obj_id == "" && $a_type == "") {
         return "";
     }
     if ($a_type == "") {
         $a_type = ilObject::_lookupType($a_obj_id);
     }
     if ($a_size == "") {
         $a_size = "big";
     }
     if ($ilSetting->get("custom_icons") && in_array($a_type, array("cat", "grp", "crs", "root"))) {
         require_once "./Services/Container/classes/class.ilContainer.php";
         if (ilContainer::_lookupContainerSetting($a_obj_id, "icon_" . $a_size)) {
             $cont_dir = ilContainer::_getContainerDirectory($a_obj_id);
             // png version? (introduced with ILIAS 4.3)
             $file_name = $cont_dir . "/icon_" . $a_size . ".png";
             if (is_file($file_name)) {
                 return $file_name;
             }
             // gif version? (prior to ILIAS 4.3)
             $file_name = $cont_dir . "/icon_" . $a_size . ".gif";
             if (is_file($file_name)) {
                 return $file_name;
             }
         }
     }
     switch ($a_size) {
         case "small":
             $suff = "";
             break;
         case "tiny":
             $suff = "_s";
             break;
         default:
             $suff = "_b";
             break;
     }
     if (!$a_offline) {
         if ($objDefinition->isPluginTypeName($a_type)) {
             include_once "./Services/Repository/classes/class.ilRepositoryObjectPlugin.php";
             return ilRepositoryObjectPlugin::_getIcon($a_type, $a_size);
         }
         return ilUtil::getImagePath("icon_" . $a_type . $suff . ".png");
     } else {
         return "./images/icon_" . $a_type . $suff . ".png";
     }
 }
 /**
  * Get Icon (object, type or plugin specific)
  * (this function should be called wherever an icon has to be displyed)
  * 
  * @param 	string		object type ("xxco")
  * @param 	string		size ("big", "small", "tiny" or "svg")
  * @param	int			object id (optional)
  * @param	int			content type id (optional)
  * @param	string		get icon of a specific level ("plugin", "type" or "object")
  * 
  * @return	string		icon path
  */
 static function _getIcon($a_type, $a_size, $a_obj_id = 0, $a_type_id = 0, $a_level = "")
 {
     // first try to use an object specific icon
     if ($a_level == "object" or $a_level == "") {
         if ($a_obj_id) {
             // always try svg version first
             $name = self::_getIconName("svg");
             $path = self::_getWebspaceDir("object", $a_obj_id) . "/" . $name;
             if (is_file($path)) {
                 return $path;
             }
             // then try older versions (big is default)
             $name = self::_getIconName($a_size);
             $path = self::_getWebspaceDir("object", $a_obj_id) . "/" . $name;
             if (is_file($path)) {
                 return $path;
             }
         }
     }
     // then try to get a content type specific icon
     if ($a_level == "type" or $a_level == "") {
         if ($a_obj_id and !$a_type_id) {
             require_once 'Customizing/global/plugins/Services/Repository/RepositoryObject/ExternalContent/classes/class.ilObjExternalContentAccess.php';
             $a_type_id = ilObjExternalContentAccess::_lookupTypeId($a_obj_id);
         }
         if ($a_type_id) {
             // always try svg version first
             $name = self::_getIconName("svg");
             $path = self::_getWebspaceDir("type", $a_type_id) . "/" . $name;
             if (is_file($path)) {
                 return $path;
             }
             // then try older versions (big is default)
             $name = self::_getIconName($a_size);
             $path = self::_getWebspaceDir("type", $a_type_id) . "/" . $name;
             if (is_file($path)) {
                 return $path;
             }
         }
     }
     // finally get the plugin icon
     if ($a_level == "plugin" or $a_level == "") {
         return parent::_getIcon($a_type, $a_size);
     }
 }