Exemple #1
0
    public function processActions(SwatTableView $view, SwatActions $actions)
    {
        $num = count($view->getSelection());
        $message = null;
        $items = SwatDB::implodeSelection($this->app->db, $view->getSelection(), 'integer');
        switch ($actions->selected->id) {
            case 'delete':
                $this->app->replacePage($this->getComponentName() . '/Delete');
                $this->app->getPage()->setItems($view->getSelection());
                break;
            case 'enable':
                $instance_id = $this->app->getInstanceId();
                $num = SwatDB::exec($this->app->db, sprintf('update BlorgAuthor set visible = %s
				where instance %s %s and id in (%s)', $this->app->db->quote(true, 'boolean'), SwatDB::equalityOperator($instance_id), $this->app->db->quote($instance_id, 'integer'), $items));
                if ($num > 0 && isset($this->app->memcache)) {
                    $this->app->memcache->flushNs('authors');
                }
                $message = new SwatMessage(sprintf(Blorg::ngettext('One author has been shown on site.', '%s authors have been shown on site.', $num), SwatString::numberFormat($num)));
                break;
            case 'disable':
                $instance_id = $this->app->getInstanceId();
                $num = SwatDB::exec($this->app->db, sprintf('update BlorgAuthor set visible = %s
				where instance %s %s and id in (%s)', $this->app->db->quote(false, 'boolean'), SwatDB::equalityOperator($instance_id), $this->app->db->quote($instance_id, 'integer'), $items));
                if ($num > 0 && isset($this->app->memcache)) {
                    $this->app->memcache->flushNs('authors');
                }
                $message = new SwatMessage(sprintf(Blorg::ngettext('One author has been hidden on site.', '%s authors have been hidden on site.', $num), SwatString::numberFormat($num)));
                break;
        }
        if ($message !== null) {
            $this->app->messages->add($message);
        }
    }
Exemple #2
0
 protected function processActions(SwatTableView $view, SwatActions $actions)
 {
     $num = count($view->getSelection());
     $message = null;
     switch ($actions->selected->id) {
         case 'delete':
             $this->app->replacePage('MetaData/Delete');
             $this->app->getPage()->setItems($view->checked_items);
             break;
         case 'show_details':
             SwatDB::updateColumn($this->app->db, 'PinholeMetaData', 'boolean:visible', true, 'id', $view->getSelection());
             $message = new SwatMessage(sprintf(Pinhole::ngettext('One detail has been enabled.', '%s details have been enabled.', $num), SwatString::numberFormat($num)));
             break;
         case 'dont_show_details':
             SwatDB::updateColumn($this->app->db, 'PinholeMetaData', 'boolean:visible', false, 'id', $view->getSelection());
             $message = new SwatMessage(sprintf(Pinhole::ngettext('One detail has been disabled.', '%s details have been disabled.', $num), SwatString::numberFormat($num)));
             break;
         case 'show_machine':
             SwatDB::updateColumn($this->app->db, 'PinholeMetaData', 'boolean:machine_tag', true, 'id', $view->getSelection());
             $message = new SwatMessage(sprintf(Pinhole::ngettext('One machine tag has been enabled.', '%s machine tags have been enabled.', $num), SwatString::numberFormat($num)));
             break;
         case 'dont_show_machine':
             SwatDB::updateColumn($this->app->db, 'PinholeMetaData', 'boolean:machine_tag', false, 'id', $view->getSelection());
             $message = new SwatMessage(sprintf(Pinhole::ngettext('One machine tag has been disabled.', '%s machine tags have been disabled.', $num), SwatString::numberFormat($num)));
             break;
     }
     if ($message !== null) {
         $this->app->messages->add($message);
     }
 }
Exemple #3
0
 protected function processActions(SwatTableView $view, SwatActions $actions)
 {
     $num = count($view->getSelection());
     switch ($actions->selected->id) {
         case 'delete':
             $this->app->replacePage('Newsletter/Delete');
             $this->app->getPage()->setItems($view->getSelection());
             break;
     }
 }
Exemple #4
0
 public function processActions(SwatTableView $view, SwatActions $actions)
 {
     $num = count($view->getSelection());
     $message = null;
     switch ($actions->selected->id) {
         case 'delete':
             $this->app->replacePage($this->getComponentName() . '/Delete');
             $this->app->getPage()->setItems($view->getSelection());
             break;
     }
     if ($message !== null) {
         $this->app->messages->add($message);
     }
 }
Exemple #5
0
    public function processActions(SwatTableView $view, SwatActions $actions)
    {
        $message = null;
        $items = SwatDB::implodeSelection($this->app->db, $view->getSelection(), 'integer');
        switch ($actions->selected->id) {
            case 'delete':
                $this->app->replacePage($this->getComponentName() . '/Delete');
                $this->app->getPage()->setItems($view->getSelection());
                break;
            case 'enable':
                $this->publishPosts($view->getSelection());
                break;
            case 'disable':
                $instance_id = $this->app->getInstanceId();
                $num = SwatDB::exec($this->app->db, sprintf('update BlorgPost set enabled = %s
				where instance %s %s and id in (%s)', $this->app->db->quote(false, 'boolean'), SwatDB::equalityOperator($instance_id), $this->app->db->quote($instance_id, 'integer'), $items));
                if ($num > 0 && isset($this->app->memcache)) {
                    $this->app->memcache->flushNs('posts');
                }
                $message = new SwatMessage(sprintf(Blorg::ngettext('One post has been hidden on site.', '%s posts have been hidden on site.', $num), SwatString::numberFormat($num)));
                break;
            case 'tags_action':
                $tag_array = $this->ui->getWidget('tags')->getSelectedTagArray();
                if (count($tag_array) > 0) {
                    $posts = $this->getPostsFromSelection($view->getSelection());
                    foreach ($posts as $post) {
                        $post->addTagsByShortname($tag_array);
                    }
                    if (isset($this->app->memcache)) {
                        $this->app->memcache->flushNs('posts');
                        $this->app->memcache->flushNs('tags');
                    }
                    $num = count($view->getSelection());
                    $num_tags = count($tag_array);
                    if ($num_tags === 1) {
                        $tag = reset($tag_array);
                        $message = new SwatMessage(sprintf(Blorg::ngettext('The tag “%s” has been added to one post.', 'The tag “%s” has been added to %s posts.', $num), SwatString::minimizeEntities($tag), SwatString::numberFormat($num)));
                    } else {
                        $message = new SwatMessage(sprintf(Blorg::ngettext('%s tags have been added to one post.', '%s tags have been added to %s posts.', $num), SwatString::numberFormat($num_tags), SwatString::numberFormat($num)));
                    }
                    // clear selected tags
                    $this->ui->getWidget('tags')->setSelectedTagArray(array());
                }
                break;
        }
        if ($message !== null) {
            $this->app->messages->add($message);
        }
    }
Exemple #6
0
 protected function processCommentsActions(SwatTableView $view, SwatActions $actions)
 {
     switch ($actions->selected->id) {
         case 'delete':
             $this->app->replacePage('Comment/Delete');
             $this->app->getPage()->setItems($view->getSelection());
             $this->app->getPage()->setPost($this->post);
             break;
     }
 }
Exemple #7
0
    /**
     * Processes photographer actions
     *
     * @param SwatTableView $view the table-view to get selected tags
     *                             from.
     * @param SwatActions $actions the actions list widget.
     */
    protected function processActions(SwatTableView $view, SwatActions $actions)
    {
        switch ($actions->selected->id) {
            case 'delete':
                $this->app->replacePage($this->getComponentName() . '/Delete');
                $this->app->getPage()->setItems($view->checked_items, $view->getColumn('checkbox')->isExtendedCheckAllSelected());
                break;
            case 'archive':
                $num = count($view->checked_items);
                $sql = sprintf('update PinholeTag set archived = true
				where PinholeTag.instance = %s and PinholeTag.id in(%s)', $this->app->db->quote($this->app->getInstanceId(), 'integer'), SwatDB::implodeSelection($this->app->db, $view->getSelection()));
                SwatDB::exec($this->app->db, $sql);
                $message = new SwatMessage(sprintf(Pinhole::ngettext('One tag has been archived.', '%s tags have been archived.', $num), SwatString::numberFormat($num)));
                $this->app->messages->add($message);
                break;
            case 'unarchive':
                $num = count($view->checked_items);
                $sql = sprintf('update PinholeTag set archived = false
				where PinholeTag.instance = %s and PinholeTag.id in(%s)', $this->app->db->quote($this->app->getInstanceId(), 'integer'), SwatDB::implodeSelection($this->app->db, $view->getSelection()));
                SwatDB::exec($this->app->db, $sql);
                $message = new SwatMessage(sprintf(Pinhole::ngettext('One tag has been set as not archived.', '%s tags have been set as not archived.', $num), SwatString::numberFormat($num)));
                $this->app->messages->add($message);
                break;
            case 'event':
                $num = count($view->checked_items);
                $sql = sprintf('update PinholeTag set event = true
				where PinholeTag.instance = %s and PinholeTag.id in(%s)', $this->app->db->quote($this->app->getInstanceId(), 'integer'), SwatDB::implodeSelection($this->app->db, $view->getSelection()));
                SwatDB::exec($this->app->db, $sql);
                $message = new SwatMessage(sprintf(Pinhole::ngettext('One tag has been set as an event.', '%s tags have been set as events.', $num), SwatString::numberFormat($num)));
                $this->app->messages->add($message);
                break;
            case 'unevent':
                $num = count($view->checked_items);
                $sql = sprintf('update PinholeTag set event = false
				where PinholeTag.instance = %s and PinholeTag.id in(%s)', $this->app->db->quote($this->app->getInstanceId(), 'integer'), SwatDB::implodeSelection($this->app->db, $view->getSelection()));
                SwatDB::exec($this->app->db, $sql);
                $message = new SwatMessage(sprintf(Pinhole::ngettext('One tag has been set as not an event.', '%s tags have been set as not events.', $num), SwatString::numberFormat($num)));
                $this->app->messages->add($message);
                break;
        }
    }
 /**
  * Processes actions on photos
  *
  * @param SwatTableView $view the view to process.
  * @param SwatActions $actions the list of actions.
  */
 public function process($view, $actions, $ui)
 {
     switch ($actions->selected->id) {
         case 'delete':
             $this->page->app->replacePage('Photo/Delete');
             $this->page->app->getPage()->setItems($view->getSelection(), $view->isExtendedCheckAllSelected());
             break;
         case 'time':
             $this->page->app->replacePage('Photo/Time');
             $this->page->app->getPage()->setItems($view->getSelection(), $view->isExtendedCheckAllSelected());
             break;
         case 'private':
             if ($ui->getWidget('passphrase')->value !== null) {
                 $this->page->app->config->pinhole->passphrase = md5($ui->getWidget('passphrase')->value);
                 $this->page->app->config->save(array('pinhole.passphrase'));
             }
             if ($this->page->app->config->pinhole->passphrase !== null) {
                 $photos = $this->getPhotos($view);
                 $num = count($photos);
                 foreach ($photos as $photo) {
                     $photo->private = true;
                     $photo->save();
                 }
                 if (isset($this->page->app->memcache)) {
                     $this->page->app->memcache->flushNs('photos');
                 }
                 $message = new SwatMessage(sprintf(Pinhole::ngettext('One photo has been set as private.', '%s photos have been set as private.', $num), SwatString::numberFormat($num)));
                 $this->page->app->messages->add($message);
             }
             break;
         case 'public':
             $photos = $this->getPhotos($view);
             $num = count($photos);
             foreach ($photos as $photo) {
                 $photo->private = true;
                 $photo->save();
             }
             if (isset($this->page->app->memcache)) {
                 $this->page->app->memcache->flushNs('photos');
             }
             $message = new SwatMessage(sprintf(Pinhole::ngettext('One photo has been set as public.', '%s photos have been set as public.', $num), SwatString::numberFormat($num)));
             $this->page->app->messages->add($message);
             break;
         case 'for_sale':
         case 'not_for_sale':
             $photos = $this->getPhotos($view);
             $num = count($photos);
             foreach ($photos as $photo) {
                 $photo->for_sale = $actions->selected->id == 'for_sale';
                 $photo->save();
             }
             if (isset($this->page->app->memcache)) {
                 $this->page->app->memcache->flushNs('photos');
             }
             if ($actions->selected->id == 'for_sale') {
                 $message = new SwatMessage(sprintf(Pinhole::ngettext('One photo has been set as for-sale.', '%s photos have been set as for-sale.', $num), SwatString::numberFormat($num)));
             } else {
                 $message = new SwatMessage(sprintf(Pinhole::ngettext('One photo has been set as not for-sale.', '%s photos have been set as not for-sale.', $num), SwatString::numberFormat($num)));
             }
             $this->page->app->messages->add($message);
             break;
         case 'publish':
         case 'status_action':
             $photos = $this->getPhotos($view);
             $num = count($photos);
             if ($ui->hasWidget('status_flydown')) {
                 $status = $ui->getWidget('status_flydown')->value;
             } else {
                 $status = PinholePhoto::STATUS_PUBLISHED;
             }
             foreach ($photos as $photo) {
                 $photo->setStatus($status);
                 $photo->save();
             }
             if (isset($this->page->app->memcache)) {
                 $this->page->app->memcache->flushNs('photos');
             }
             $message = new SwatMessage(sprintf(Pinhole::ngettext('One photo has been updated to “%2$s”.', '%1$s photos have been updated to “%2$s”.', $num), SwatString::numberFormat($num), PinholePhoto::getStatusTitle($status)));
             $this->page->app->messages->add($message);
             break;
         case 'tags_action':
             $tag_array = $ui->getWidget('tags')->getSelectedTagArray();
             if (count($tag_array) > 0) {
                 $photos = $this->getPhotos($view);
                 $num = count($photos);
                 foreach ($photos as $photo) {
                     $photo->addTagsByName($tag_array);
                 }
                 if (isset($this->page->app->memcache)) {
                     $this->page->app->memcache->flushNs('photos');
                 }
                 if (count($tag_array) > 1) {
                     $message = new SwatMessage(sprintf(Pinhole::ngettext('%s tags have been added to one photo.', '%s tags have been added to %s photos.', $num), SwatString::numberFormat(count($tag_array)), SwatString::numberFormat($num)));
                 } else {
                     $message = new SwatMessage(sprintf(Pinhole::ngettext('A tag has been added to one photo.', 'A tag has been added to %s photos.', $num), SwatString::numberFormat($num)));
                 }
                 $this->page->app->messages->add($message);
             }
             // reset tag list
             $ui->getWidget('tags')->setSelectedTagArray(array());
             break;
     }
 }