Пример #1
0
 public function doExecApplier()
 {
     $form = new MyQuickForm('applyform', 'POST', M_Office::URL());
     $opts = M::tablesWithPlugin('tag');
     $opts = array_combine($opts, $opts);
     $form->addElement('select', 'table', 'Table', $opts);
     $form->addElement('textarea', 'clause', 'clause', 'rows="4" cols="60"');
     $form->addElement('text', 'tagname', 'tagname');
     $form->addElement('text', 'tagdel', 'tagdel');
     $form->addElement('checkbox', 'distinct', 'distinct');
     $form->addElement('submit', '__submit__', 'Apply');
     $form->addFormRule(array($this, 'checkApplier'));
     if ($form->validate()) {
         @set_time_limit(0);
         ini_set('memory_limit', '1024M');
         $values = $form->exportValues();
         $t = DB_DataObject::factory($values['table']);
         $query = 'SELECT ' . ($values['distinct'] ? 'DISTINCT ' : ' ') . $values['table'] . '.* FROM ' . $values['table'] . ' ' . $values['clause'];
         $t->query($query);
         while ($t->fetch()) {
             if ($values['tagname']) {
                 $t->addTag($values['tagname']);
             }
             if ($values['tagdel']) {
                 $t->removeTag($values['tagdel']);
             }
             $applied++;
         }
         $this->assign('success', 1);
         $this->assign('applied', $applied);
     }
     $this->assign('form', $form);
 }
Пример #2
0
 public function execute($params)
 {
     if (count($params) > 0) {
         $tables = $params;
     } else {
         $tables = M::tablesWithPlugin('tag');
     }
     foreach ($tables as $table) {
         $records = DB_DataObject::factory($table);
         $records->find();
         $records->unloadPlugins();
         $this->line('');
         $this->line("clearing cache on {$table}");
         foreach ($records as $record) {
             $record->getPlugin('tag')->clearTagCache($record);
             echo '.';
         }
     }
 }