Exemple #1
0
    public function formatElementItem($activity, $fallback = FALSE)
    {
        switch ($activity['item_type']) {
            // Pages and Page Templates
            case 'pages':
                // Is is a Page Template?
                $is_template = !is_numeric($activity['item_id']);
                // Fetch the page from the DB
                $page = Symphony::Database()->fetch('
						SELECT `title`
						FROM `tbl_pages`
						WHERE `' . ($is_template ? 'handle' : 'id') . '` = "' . $activity['item_id'] . '"');
                // If the page no longer exists, use the fallback description
                if (empty($page)) {
                    $item = $activity['fallback_description'];
                } elseif ($is_template) {
                    $item = __(' the %1s page %2s', array($page[0]['title'], $fallback ? __('template') : Widget::Anchor(__('template'), URL . '/symphony/blueprints/pages/template/' . $activity['item_id'])->generate()));
                    // Or if it was the page config, build that description
                } else {
                    $item = __(' the %1s page', array($fallback ? $page[0]['title'] : Widget::Anchor($page[0]['title'], URL . '/symphony/blueprints/pages/edit/' . $activity['item_id'])->generate()));
                }
                break;
            case "events":
                // Grab the event info
                $handle = EventManager::__getHandleFromFilename($activity['item_id']);
                $about = EventManager::about($handle);
                // If the event no longer exists, use the fallback description
                if (empty($about)) {
                    $item = $activity['fallback_description'];
                } else {
                    $item = __(' the %1s event', array($fallback ? $about['name'] : Widget::Anchor($about['name'], URL . '/symphony/blueprints/events/edit/' . $handle)->generate()));
                }
                break;
            case "datasources":
                // Grab the DS info
                $handle = DatasourceManager::__getHandleFromFilename($activity['item_id']);
                $about = DatasourceManager::about($handle);
                // If the DS no longer exists, use the fallback description
                if (empty($about)) {
                    $item = $activity['fallback_description'];
                } else {
                    $item = __(' the %1s data source', array($fallback ? $about['name'] : Widget::Anchor($about['name'], URL . '/symphony/blueprints/datasources/edit/' . $handle)->generate()));
                }
                break;
            case "utilities":
                // If the utility no longer exists, use the fallback description
                if (!file_exists(UTILITIES . '/' . $activity['item_id'])) {
                    $item = $activity['fallback_description'];
                } else {
                    $item = __(' the %1s utility', array($fallback ? $activity['item_id'] : Widget::Anchor($activity['item_id'], URL . '/symphony/blueprints/utilities/edit/' . str_replace('.xsl', '', $activity['item_id']))->generate()));
                }
                break;
            case "sections":
                // Grab the section info
                $section = SectionManager::fetch($activity['item_id']);
                // If the section no longer exists, use the fallback description
                if (!$section instanceof Section) {
                    $item = $activity['fallback_description'];
                } else {
                    $item = __(' the %1s section', array($fallback ? $section->get('name') : Widget::Anchor($section->get('name'), URL . '/symphony/blueprints/sections/edit/' . $activity['item_id'])->generate()));
                }
                break;
            case "authors":
                // Grab the author info
                $author = AuthorManager::fetchByID($activity['item_id']);
                // If the author no longer exists, use the fallback description
                if (!$author instanceof Author) {
                    $item = $activity['fallback_description'];
                } else {
                    // If the author edited their own record
                    if ($activity['user_id'] == $activity['item_id']) {
                        $item = __(' his/her %1s', array($fallback ? __('author record') : Widget::Anchor(__('author record'), URL . '/symphony/system/authors/edit/' . $activity['item_id'])->generate()));
                    } else {
                        $item = __(' the author record for %1s', array($fallback ? $author->getFullName() : Widget::Anchor($author->getFullName(), URL . '/symphony/system/authors/edit/' . $activity['item_id'])->generate()));
                    }
                }
                break;
            case "preferences":
                $item = __(' the %s', array(Widget::Anchor(__('system preferences'), URL . '/symphony/system/preferences')->generate()));
                break;
            case "maintenance-mode":
                $item = __(' maintenance mode');
                break;
            case "extensions":
                try {
                    $about = ExtensionManager::about($activity['item_id']);
                } catch (Exception $e) {
                    $about = NULL;
                }
                if (empty($about)) {
                    $item = $activity['fallback_description'];
                } else {
                    $item = __('the %1s extension', array($about['name']));
                }
                break;
            case "login":
                $item = __(' to the back end');
                break;
            case "password-reset":
                $item = __(' his/her password');
                break;
            default:
                $item = NULL;
                break;
        }
        return $item;
    }