]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/Sitemap/SitemapPlugin.php
Merge remote-tracking branch 'upstream/master' into social-master
[quix0rs-gnu-social.git] / plugins / Sitemap / SitemapPlugin.php
index 36041cfc9a025d7edcbb0368438bf1d03661081e..bab0d9fa9bb1ade283a28e72cc9296aca42cc0d7 100644 (file)
@@ -49,37 +49,6 @@ class SitemapPlugin extends Plugin
     const USERS_PER_MAP   = 50000;
     const NOTICES_PER_MAP = 50000;
 
-    /**
-     * Load related modules when needed
-     *
-     * @param string $cls Name of the class to be loaded
-     *
-     * @return boolean hook value; true means continue processing, false means stop.
-     */
-    function onAutoload($cls)
-    {
-        $dir = dirname(__FILE__);
-
-        switch ($cls)
-        {
-        case 'Sitemap_user_count':
-        case 'Sitemap_notice_count':
-            require_once $dir . '/' . $cls . '.php';
-            return false;
-        case 'SitemapindexAction':
-        case 'NoticesitemapAction':
-        case 'UsersitemapAction':
-        case 'SitemapadminpanelAction':
-            require_once $dir . '/' . strtolower(mb_substr($cls, 0, -6)) . '.php';
-            return false;
-        case 'SitemapAction':
-            require_once $dir . '/' . strtolower($cls) . '.php';
-            return false;
-        default:
-            return true;
-        }
-    }
-
     /**
      * Add sitemap-related information at the end of robots.txt
      *
@@ -99,23 +68,23 @@ class SitemapPlugin extends Plugin
     /**
      * Map URLs to actions
      *
-     * @param Net_URL_Mapper $m path-to-action mapper
+     * @param URLMapper $m path-to-action mapper
      *
      * @return boolean hook value; true means continue processing, false means stop.
      */
-    function onRouterInitialized($m)
+    public function onRouterInitialized(URLMapper $m)
     {
         $m->connect('sitemapindex.xml',
                     array('action' => 'sitemapindex'));
 
-        $m->connect('/notice-sitemap-:year-:month-:day-:index.xml',
+        $m->connect('notice-sitemap-:year-:month-:day-:index.xml',
                     array('action' => 'noticesitemap'),
                     array('year' => '[0-9]{4}',
                           'month' => '[01][0-9]',
                           'day' => '[0123][0-9]',
                           'index' => '[1-9][0-9]*'));
 
-        $m->connect('/user-sitemap-:year-:month-:day-:index.xml',
+        $m->connect('user-sitemap-:year-:month-:day-:index.xml',
                     array('action' => 'usersitemap'),
                     array('year' => '[0-9]{4}',
                           'month' => '[01][0-9]',
@@ -180,32 +149,12 @@ class SitemapPlugin extends Plugin
     {
         $schema = Schema::get();
 
-        $schema->ensureTable('sitemap_user_count',
-                             array(new ColumnDef('registration_date', 'date', null,
-                                                 true, 'PRI'),
-                                   new ColumnDef('user_count', 'integer'),
-                                   new ColumnDef('created', 'datetime',
-                                                 null, false),
-                                   new ColumnDef('modified', 'timestamp')));
-
-        $schema->ensureTable('sitemap_notice_count',
-                             array(new ColumnDef('notice_date', 'date', null,
-                                                 true, 'PRI'),
-                                   new ColumnDef('notice_count', 'integer'),
-                                   new ColumnDef('created', 'datetime',
-                                                 null, false),
-                                   new ColumnDef('modified', 'timestamp')));
-
-        $userCreated = $schema->getColumnDef('user', 'created');
-
-        if (empty($userCreated) || $userCreated->key != 'MUL') {
-            $schema->createIndex('user', 'created');
-        }
-
+        $schema->ensureTable('sitemap_user_count', Sitemap_user_count::schemaDef());
+        $schema->ensureTable('sitemap_notice_count', Sitemap_notice_count::schemaDef());
         return true;
     }
 
-    function onEndAdminPanelNav($menu) {
+    function onEndAdminPanelNav(Menu $menu) {
         if (AdminPanelAction::canAdmin('sitemap')) {
             // TRANS: Menu item title/tooltip
             $menu_title = _m('Sitemap configuration');
@@ -225,12 +174,12 @@ class SitemapPlugin extends Plugin
      *
      * @return boolean hook value
      */
-    function onPluginVersion(&$versions)
+    function onPluginVersion(array &$versions)
     {
         $url = 'http://status.net/wiki/Plugin:Sitemap';
 
         $versions[] = array('name' => 'Sitemap',
-            'version' => STATUSNET_VERSION,
+            'version' => GNUSOCIAL_VERSION,
             'author' => 'Evan Prodromou',
             'homepage' => $url,
             'rawdescription' =>