private function setIcon($icon_id, $option_value_id) { try { // Récupère l'application $application = $this->getApplication(); // Charge l'option_value $option_value = new Application_Model_Option_Value(); $option_value->find($option_value_id); // Charge l'icône $icon = new Media_Model_Library_Image(); $icon->find($icon_id); if (!$icon->getId() or $icon->getLibraryId() != $option_value->getLibraryId() && $option_value->getCode() != 'folder') { throw new Exception($this->_('An error occurred while saving. The selected icon is not valid.')); } // Tout va bien, on met à jour l'icône pour cette option_value $option_value->setIconId($icon->getId())->setIcon(null)->save(); $icon_url = $option_value->resetIconUrl()->getIconUrl(true); $colored_header_icon_url = $icon_url; if ($option_value->getImage()->getCanBeColorized()) { $header_color = $application->getDesignBlock('header')->getColor(); $colored_header_icon_url = $this->getUrl('template/block/colorize', array('id' => $option_value->getIconId(), 'color' => str_replace('#', '', $header_color))); } $return = array('colored_header_icon_url' => $colored_header_icon_url, 'icon_url' => $icon_url); return $return; } catch (Exception $e) { return false; } }