Exemple #1
0
 /**
  * Called when migrating up.
  */
 public function up()
 {
     $timeThen = microtime(true);
     dbexec('DELETE FROM #__nodes WHERE `type` LIKE \'%ComBaseDomainEntityComment%\' AND `parent_type` = \'com:todos.domain.entity.milestone\' ');
     dbexec('DELETE FROM #__nodes WHERE `type` LIKE \'%com:todos.domain.entity.milestone\' ');
     dbexec('DELETE FROM #__edges WHERE `node_b_type` LIKE \'%com:todos.domain.entity.milestone\' ');
     dbexec('DROP TABLE #__todos_milestones');
     //clearing todolists from the data
     $todolists = dbfetch('SELECT `id`, `parent_id`, `alias` FROM #__nodes WHERE `type` LIKE \'%com:todos.domain.entity.todolist\' ');
     foreach ($todolists as $todolist) {
         $terms = explode('-', $todolist['alias']);
         foreach ($terms as $index => $value) {
             if (strlen($value) < 3) {
                 unset($terms[$index]);
             }
         }
         $todos = KService::get('com://site/todos.domain.entity.todo')->getRepository()->getQuery()->disableChain()->where('parent_id = ' . $todolist['id'])->fetchSet();
         foreach ($todos as $todo) {
             foreach ($terms as $term) {
                 if (strlen($term) > 3) {
                     dboutput($term . ', ');
                     $todo->set('parent_id', 0)->set('description', $todo->description . ' #' . trim($term))->addHashtag($term)->save();
                 }
             }
         }
     }
     dbexec('DELETE FROM #__nodes WHERE `type` LIKE \'%com:todos.domain.entity.todolist\' ');
     //clear stories
     dbexec('DELETE FROM #__nodes WHERE `story_object_type` = \'com:todos.domain.entity.todolist\' OR `story_object_type` = \'com:todos.domain.entity.milestone\' ');
     dbexec('DROP TABLE #__todos_todolists');
     $timeDiff = microtime(true) - $timeThen;
     dboutput("TIME: ({$timeDiff})" . "\n");
 }
Exemple #2
0
 /**
  * Called when migrating up
  */
 public function up()
 {
     $timeThen = microtime(true);
     //converting the old boards as hashtags
     $boards = dbfetch('SELECT `id`, `alias` FROM #__anahita_nodes WHERE `type` LIKE \'%com:topics.domain.entity.board\' ');
     foreach ($boards as $board) {
         $terms = explode('-', $board['alias']);
         foreach ($terms as $index => $value) {
             if (strlen($value) < 3) {
                 unset($terms[$index]);
             }
         }
         $topics = KService::get('com://site/topics.domain.entity.topic')->getRepository()->getQuery()->disableChain()->where('parent_id = ' . $board['id'])->fetchSet();
         foreach ($topics as $topic) {
             foreach ($terms as $term) {
                 if (strlen($term) > 3) {
                     dboutput($term . ', ');
                     $topic->set('description', $topic->description . ' #' . trim($term))->addHashtag($term)->save();
                 }
             }
         }
     }
     dbexec('UPDATE #__anahita_nodes SET `parent_id` = 0 WHERE `type` LIKE \'%com:topics.domain.entity.topic\'');
     dbexec('DELETE FROM #__anahita_nodes WHERE `type` LIKE \'%com:topics.domain.entity.board\'');
     dbexec('DELETE FROM #__anahita_edges WHERE `node_b_type` LIKE \'%com:topics.domain.entity.board\'');
     dbexec('DROP TABLE #__topics_boards');
     $timeDiff = microtime(true) - $timeThen;
     dboutput("TIME: ({$timeDiff})" . "\n");
 }
Exemple #3
0
 /**
  * Called when migrating up
  */
 public function up()
 {
     $timeThen = microtime(true);
     //some legacy cleanup
     $legacyTables = array('categories', 'content', 'content_frontpage', 'core_log_items', 'migration_backlinks', 'migrations', 'sections', 'stats_agents', 'tagmeta', 'core_log_searches');
     foreach ($legacyTables as $legacyTable) {
         dbexec('DROP TABLE IF EXISTS #__' . $legacyTable);
     }
     //delete a legacy record
     dbexec('DELETE FROM #__components WHERE `option` = \'com_mailto\' ');
     //add the hashtag contentfilter
     dbexec('INSERT INTO #__plugins (name,element,folder,iscore) VALUES (\'Hashtag\', \'hashtag\',\'contentfilter\',1)');
     //create the fields required for creating hashtag nodes
     dbexec('ALTER TABLE #__anahita_nodes DROP COLUMN `tag_count`');
     dbexec('ALTER TABLE #__anahita_nodes DROP COLUMN `tag_ids`');
     //install the hashtag related extensions
     dbexec('INSERT INTO #__components (`name`,`link`,`option`,`iscore`,`enabled`) VALUES (\'Hashtags\',\'option=com_hashtags\',\'com_hashtags\',1,1)');
     $ids = array();
     //fetch only the nodes that contain something that resembels a hashtag
     $query_regexp = 'body REGEXP \'#([^0-9_\\s\\W].{2,})\'';
     dboutput("\nActors' Hashtags\n");
     //extracting hashtag terms from actors
     $ids = dbfetch('SELECT id FROM #__anahita_nodes WHERE type LIKE \'ComActorsDomainEntityActor%\' AND ' . $query_regexp);
     foreach ($ids as $id) {
         $entity = KService::get('com://site/actors.domain.entity.actor')->getRepository()->getQuery()->disableChain()->fetch($id);
         $hashtagTerms = $this->extractHashtagTerms($entity->description);
         foreach ($hashtagTerms as $term) {
             dboutput($term . ', ');
             $entity->addHashtag($term)->save();
         }
     }
     dboutput("\nComments' hashtags\n");
     //extracting hashtag terms from comments
     $ids = dbfetch('SELECT id FROM #__anahita_nodes WHERE type LIKE \'ComBaseDomainEntityComment%\' AND ' . $query_regexp);
     foreach ($ids as $id) {
         $entity = KService::get('com://site/base.domain.entity.comment')->getRepository()->getQuery()->disableChain()->fetch($id);
         $hashtagTerms = $this->extractHashtagTerms($entity->body);
         foreach ($hashtagTerms as $term) {
             dboutput($term . ', ');
             $entity->addHashtag($term)->save();
         }
     }
     dboutput("\nMedia's Hashtags\n");
     //extracting hashtag terms from mediums: notes, topics, pages, and todos
     $query = 'SELECT id FROM #__anahita_nodes WHERE ' . $query_regexp . ' AND ( ' . 'type LIKE \'%com:notes.domain.entity.note\' ' . 'OR type LIKE \'%com:topics.domain.entity.topic\' ' . 'OR type LIKE \'%com:photos.domain.entity.photo\' ' . 'OR type LIKE \'%com:photos.domain.entity.set\' ' . 'OR type LIKE \'%com:pages.domain.entity.page\' ' . 'OR type LIKE \'%com:todos.domain.entity.todo\' ' . ' ) ';
     $ids = dbfetch($query);
     foreach ($ids as $id) {
         $entity = KService::get('com://site/medium.domain.entity.medium')->getRepository()->getQuery()->disableChain()->fetch($id);
         $hashtagTerms = $this->extractHashtagTerms($entity->description);
         foreach ($hashtagTerms as $term) {
             dboutput($term . ', ');
             $entity->addHashtag($term)->save();
         }
     }
     dbexec('UPDATE #__plugins SET published = 1 WHERE element = \'hashtag\'');
     $timeDiff = microtime(true) - $timeThen;
     dboutput("TIME: ({$timeDiff})" . "\n");
 }
Exemple #4
0
 /**
  * Called when migrating up
  */
 public function up()
 {
     //looks like these two didn't work in previous migrations
     dbexec("DROP TABLE #__content_rating");
     dbexec("DELETE FROM #__components WHERE `option` IN  ('com_media', 'com_menus', 'com_modules')");
     //add github gist plugin
     dbexec("INSERT INTO `#__plugins` (`id`, `name`, `element`, `folder`, `access`, `ordering`, `published`, `iscore`, `client_id`, `checked_out`, `checked_out_time`, `params`) VALUES (49, 'Content Filter - GithubGist', 'gist', 'contentfilter', 0, 0, 0, 0, 0, 0, '0000-00-00 00:00:00', '')");
     //remove the syntax plugin
     dbexec("DELETE FROM #__plugins WHERE `element` IN ('syntax', 'ptag') ");
     //UTF-8 conversions
     dbexec("ALTER DATABASE CHARACTER SET utf8");
     dbexec("ALTER TABLE #__anahita_edges CHARACTER SET utf8");
     dbexec("ALTER TABLE #__anahita_nodes CHARACTER SET utf8");
     dbexec("ALTER TABLE #__anahita_nodes CHANGE name name VARBINARY(255)");
     dbexec("ALTER TABLE #__anahita_nodes CHANGE name name VARCHAR(255) CHARACTER SET utf8");
     dbexec("ALTER TABLE #__anahita_nodes CHANGE alias alias VARBINARY(255)");
     dbexec("ALTER TABLE #__anahita_nodes CHANGE alias alias VARCHAR(255) CHARACTER SET utf8");
     dbexec("ALTER TABLE #__anahita_nodes CHANGE body body MEDIUMBLOB");
     dbexec("ALTER TABLE #__anahita_nodes CHANGE body body MEDIUMTEXT CHARACTER SET utf8");
     dbexec("ALTER TABLE #__anahita_nodes CHANGE person_given_name person_given_name VARBINARY(255)");
     dbexec("ALTER TABLE #__anahita_nodes CHANGE person_given_name person_given_name VARCHAR(255) CHARACTER SET utf8");
     dbexec("ALTER TABLE #__anahita_nodes CHANGE person_family_name person_family_name VARBINARY(255)");
     dbexec("ALTER TABLE #__anahita_nodes CHANGE person_family_name person_family_name VARCHAR(255) CHARACTER SET utf8");
     dbexec("ALTER TABLE #__migrator_migrations CHARACTER SET utf8");
     dbexec("ALTER TABLE #__migrator_versions CHARACTER SET utf8");
     dbexec("ALTER TABLE #__opensocial_profiles CHARACTER SET utf8");
     dbexec("ALTER TABLE #__opensocial_profiles CHARACTER SET utf8");
     //move these to related components
     dbexec("ALTER TABLE #__invites_tokens CHARACTER SET utf8");
     dbexec("ALTER TABLE #__opensocial_profiles CHARACTER SET utf8");
     dbexec("ALTER TABLE #__subscriptions_coupons CHARACTER SET utf8");
     dbexec("ALTER TABLE #__subscriptions_packages CHARACTER SET utf8");
     dbexec("ALTER TABLE #__subscriptions_transactions CHARACTER SET utf8");
     dbexec("ALTER TABLE #__subscriptions_vats CHARACTER SET utf8");
     dbexec("ALTER TABLE #__todos_todos CHARACTER SET utf8");
     dbexec("ALTER TABLE #__topics_topics CHARACTER SET utf8");
     dbexec("ALTER TABLE #__users CHARACTER SET utf8");
     dbexec("ALTER TABLE #__users CHANGE name name VARBINARY(255)");
     dbexec("ALTER TABLE #__users CHANGE name name VARCHAR(255) CHARACTER SET utf8");
     //updating comments
     $timeThen = microtime(true);
     $db = KService::get('koowa:database.adapter.mysqli');
     //change comment formats from html to string
     $entities = dbfetch('SELECT id, body FROM #__anahita_nodes WHERE type LIKE "ComBaseDomainEntityComment%" ');
     dboutput("Updating comments. This WILL take a while ...\n");
     foreach ($entities as $entity) {
         $id = $entity['id'];
         $body = strip_tags($entity['body']);
         $db->update('anahita_nodes', array('body' => $body), ' WHERE id=' . $id);
     }
     dboutput("Comments updated!\n");
     $timeDiff = microtime(true) - $timeThen;
     dboutput("TIME: ({$timeDiff})" . "\n");
 }
Exemple #5
0
 /**
  * Called when migrating up.
  */
 public function up()
 {
     $timeThen = microtime(true);
     $db = KService::get('koowa:database.adapter.mysqli');
     //change todo formats from html to string
     $entities = dbfetch('SELECT id, body FROM #__nodes WHERE type LIKE "%com:todos.domain.entity.todo" ');
     foreach ($entities as $entity) {
         $id = $entity['id'];
         $body = strip_tags($entity['body']);
         $db->update('nodes', array('body' => $body), ' WHERE id=' . $id);
     }
     $timeDiff = microtime(true) - $timeThen;
     dboutput("TIME: ({$timeDiff})" . "\n");
 }
Exemple #6
0
 /**
  * Called when migrating up
  */
 public function up()
 {
     $timeThen = microtime(true);
     $db = KService::get('koowa:database.adapter.mysqli');
     dboutput("Updating Topics. This may take a while ...\n");
     //Use p tags instead of inlines for topics
     $entities = dbfetch('SELECT id, body FROM #__anahita_nodes WHERE type LIKE "%com:topics.domain.entity.topic" ');
     foreach ($entities as $entity) {
         $id = $entity['id'];
         $entity['body'] = strip_tags($entity['body'], '<i><b><h1><h2><h3><h4><ul><ol><li><blockquote><pre>');
         $body = preg_replace('/\\n(\\s*\\n)+/', "</p>\n<p>", $entity['body']);
         $body = '<p>' . $body . '</p>';
         $db->update('anahita_nodes', array('body' => $body), ' WHERE id=' . $id);
     }
     dboutput("Topics updated!\n");
     $timeDiff = microtime(true) - $timeThen;
     dboutput("TIME: ({$timeDiff})" . "\n");
 }
Exemple #7
0
/**
 * Fetches a row of data from the database
 *
 * @param string  $select The Select query
 * @param int     $mode   The fetch mode. @see KDatabase
 * 
 * @return mixed
 */
function dbfetch($select, $mode = KDatabase::FETCH_ARRAY_LIST)
{
    $select = str_replace('jos_', '#__', $select);
    $db = KService::get('koowa:database.adapter.mysqli');
    $then = microtime();
    $result = $db->select($select, $mode);
    $diff = microtime() - $then;
    dboutput("QUERY: " . $select . " ({$diff})" . "\n");
    return $result;
}