Mnemo::initialize PHP Method

initialize() public static method

Defines the following $GLOBALS (@TODO these should use the injector) mnemo_shares display_notepads
public static initialize ( )
    public static function initialize()
    {
        $GLOBALS['mnemo_shares'] = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Share')->create();
        // Update the preference for which notepads to display. If the
        // user doesn't have any selected notepads for view then fall
        // back to some available notepad.
        $GLOBALS['display_notepads'] = unserialize($GLOBALS['prefs']->getValue('display_notepads'));
        if (($actionID = Horde_Util::getFormData('actionID')) !== null) {
            $notepadId = Horde_Util::getFormData('display_notepad');
            switch ($actionID) {
                case 'add_displaylist':
                    if (!in_array($notepadId, $GLOBALS['display_notepads'])) {
                        $GLOBALS['display_notepads'][] = $notepadId;
                    }
                    break;
                case 'remove_displaylist':
                    if (in_array($notepadId, $GLOBALS['display_notepads'])) {
                        $key = array_search($notepadId, $GLOBALS['display_notepads']);
                        unset($GLOBALS['display_notepads'][$key]);
                    }
            }
        }
        // Make sure all notepads exist now, to save on checking later.
        $_temp = $GLOBALS['display_notepads'] ? $GLOBALS['display_notepads'] : array();
        $_all = self::listNotepads();
        $GLOBALS['display_notepads'] = array();
        foreach ($_temp as $id) {
            if (isset($_all[$id])) {
                $GLOBALS['display_notepads'][] = $id;
            }
        }
        // All notepads for guests.
        if (!count($GLOBALS['display_notepads']) && !$GLOBALS['registry']->getAuth()) {
            $GLOBALS['display_notepads'] = array_keys($_all);
        }
        /* If the user doesn't own a notepad, create one. */
        $notepads = $GLOBALS['injector']->getInstance('Mnemo_Factory_Notepads')->create();
        if (($new_default = $notepads->ensureDefaultShare()) !== null) {
            $GLOBALS['display_notepads'][] = $new_default;
            $GLOBALS['prefs']->setValue('default_notepad', $new_default);
        }
        $GLOBALS['prefs']->setValue('display_notepads', serialize($GLOBALS['display_notepads']));
    }

Usage Example

コード例 #1
0
ファイル: Application.php プロジェクト: horde/horde
 /**
  * Global variables defined:
  *   $mnemo_shares - TODO
  */
 protected function _init()
 {
     /* For now, autoloading the Content_* classes depend on there being a
      * registry entry for the 'content' application that contains at least
      * the fileroot entry. */
     $GLOBALS['injector']->getInstance('Horde_Autoloader')->addClassPathMapper(new Horde_Autoloader_ClassPathMapper_Prefix('/^Content_/', $GLOBALS['registry']->get('fileroot', 'content') . '/lib/'));
     if (!class_exists('Content_Tagger')) {
         throw new Horde_Exception(_("The Content_Tagger class could not be found. Make sure the Content application is installed."));
     }
     Mnemo::initialize();
 }
All Usage Examples Of Mnemo::initialize