Перейти к содержимому


Фотография
- - - - -

JBImage questions and suggestions


  • Закрытая тема Тема закрыта
Сообщений в теме: 10

#1 Julio

Julio

Отправлено 06 July 2013 - 15:27

Hi,
First of all, congratulations for JBZoo. It's a nice app and improve some important things at Zoo.

I'm trying to create a colaborative web site, with user generated content. My first idea is use the Zoo to get and publish the content from users (managed by Community Builder).  I decide to use JBZoo because my content needs some flexible element to post images and JBImage sounds to be perfect. However, my problem is: how to seperate images posted by one user than others? Because the element uses just one path to store all image files, is it correct? With this, when the user "A" upload a picture, the user "B" will see that pitcture in his list of "Already uploaded?". This is a huge privacy problem for me. There are some solution for it?

In my point of view, the JBImage needs to have an option like "respect user privacy" in element configuration. When this flag is set to "yes", the element will use the "Upload path" as the base  path and creates directories inside it to store the image files. The directories will be named as the user IDs and, inside the user IDs, create new directories with the Zoo iten ID (i don't know if it is easy to implement. Probably this ID will be created just when form be posted).

 

Another nice improvement to JBImage will be create a new kind of template: "gallery". When this template is selected, the element will show the same options of Zoo Gallery element and will be showed as one Zoo Gallery element in the front end (except for the submition).

 

So, how can you help me?

 



#2 Sliapy

Sliapy

Отправлено 06 July 2013 - 15:45

In my point of view, the JBImage needs to have an option like "respect user privacy" in element configuration. When this flag is set to "yes", the element will use the "Upload path" as the base  path and creates directories inside it to store the image files. The directories will be named as the user IDs and, inside the user IDs, create new directories with the Zoo iten ID (i don't know if it is easy to implement. Probably this ID will be created just when form be posted).  

Actually, JBZoo Image already have this option :)

 

ssmb5c73ca9_200x0.png


  • 0
[color=#aa0000]Не забывайте нажимать кнопку "Вопрос Решён" под сообщением, которое решило Вашу проблему.[/color]

#3 Julio

Julio

Отправлено 06 July 2013 - 16:38

Thanks!

Now I have a new problem to be addressed.

Can I use the JBImage element with Zoo Blog and Page apps? Or can I copy and use default Zoo Blog templates (like Sans and Warp6) to JBZoo App?



#4 Julio

Julio

Отправлено 06 July 2013 - 16:58

Thanks!

Now I have a new problem to be addressed.

Can I use the JBImage element with Zoo Blog and Page apps? Or can I copy and use default Zoo Blog templates (like Sans and Warp6) to JBZoo App?

 

Now I tried both options and the situation is the same for them: The JBImage element works with some problems in the submission form. I cant delete the photo, the search button appears gray (but works), the path to the selected file to be upload is not showed in the search box and other things like that.



#5 SmetDenis

SmetDenis

Отправлено 06 July 2013 - 17:51

Can I use the JBImage element with Zoo Blog and Page apps? Or can I copy and use default Zoo Blog templates (like Sans and Warp6) to JBZoo App?

 

JBImage will be work only in JBZoo App

Now I tried both options and the situation is the same for them: The JBImage element works with some problems in the submission form. I cant delete the photo, the search button appears gray (but works), the path to the selected file to be upload is not showed in the search box and other things like that.

 

Can you give me a direct link to your submission ?


  • 0
JBZoo v4.0 и новый чудный мир Open Source GPL
Отключайте проверку лицензий как можно скорее!



— Есть два типа людей: Кто еще не делает бекапы и кто уже делает бекапы.


#6 Julio

Julio

Отправлено 06 July 2013 - 18:35

My website is under construction.

When I use JBZoo App and Catalog Template the submission is ok. My problem in this scenario was the category page configuration to show the content for all users. JBZoo is more complex and I had some problems to configure it. My target is an simple 3 columns page for category page. I did it, however, the layout with background and borders for the content is not appropriate to my layout.  Could you help me to remove it?



#7 Julio

Julio

Отправлено 06 July 2013 - 20:39

Now, my problem is the integration with other modules that works with Zoo.

I'm using the RokSprocket module to show content at home page. However, this module don't recognize the JBImage as a default image and I cant show pitures at home. There are some way to make the first image of my JBImage element be recognized as defaut image?

Im sorry for large topic, but I'm reporting here the critical steps of my project using JBImage because I think that it's going to be useful for other users.

Thanks a lot for the support.



#8 Julio

Julio

Отправлено 06 July 2013 - 23:26

Problem with RokSprocket and JBImage element solved. I hacked the RokSprocket module code for it and add the type "jbimage" as a new kind of acceptable image source and fix the code to take the first image.



#9 SmetDenis

SmetDenis

Отправлено 07 July 2013 - 06:58

Problem with RokSprocket and JBImage element solved. I hacked the RokSprocket module code for it and add the type "jbimage" as a new kind of acceptable image source and fix the code to take the first image.

 

Can you share your solution? So other users can also solve this problem. 


Сообщение отредактировал Sliapy: 07 July 2013 - 17:58

  • 0
JBZoo v4.0 и новый чудный мир Open Source GPL
Отключайте проверку лицензий как можно скорее!



— Есть два типа людей: Кто еще не делает бекапы и кто уже делает бекапы.


#10 Julio

Julio

Отправлено 07 July 2013 - 22:23

To solve the RokSprocket problem, you will need to add another type of Zoo element (jbimage) to be processed as an image. To do it, edit the file  /components/com_roksprocket/lib/RokSprocket/Provider/Zoo.php

 

My final code is:

<?php
/**
 * @version   $Id: Zoo.php 10887 2013-05-30 06:31:57Z btowles $
 * @author    RocketTheme http://www.rockettheme.com
 * @copyright Copyright (C) 2007 - 2013 RocketTheme, LLC
 * @license   http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 only
 */

class RokSprocket_Provider_Zoo extends RokSprocket_Provider_AbstarctJoomlaBasedProvider
{
    /**
     * @return RokSprocket_ItemCollection
     */
    public function getItems()
    {
        if ($this->params->exists('zoo_application_type')) {
            $this->filters['zoo_application_type'][] = $this->params->get('zoo_application_type');
        }
        return parent::getItems();
    }

    /**
     * @static
     * @return bool
     */
    public static function isAvailable()
    {
        if (!class_exists('JFactory')) {
            return false;
        }
        $db = JFactory::getDbo();
        $query = $db->getQuery(true);

        $query->select('a.extension_id');
        $query->from('#__extensions AS a');
        $query->where('a.type = "component"');
        $query->where('a.element = "com_zoo"');
        $query->where('a.enabled = 1');

        $db->setQuery($query);

        if ($db->loadResult()) {
            return true;
        } else {
            return false;
        }

    }

    /**
     * @param array $filters
     * @param array $sort_filters
     */
    public function __construct($filters = array(), $sort_filters = array())
    {
        parent::__construct('zoo');
        $this->setFilterChoices($filters, $sort_filters);
    }

    /**
     * @param     $raw_item
     * @param int $dborder
     *
     * @return \RokSprocket_Item
     */
    protected function convertRawToItem($raw_item, $dborder = 0)
    {
        $app_type = $this->params->get('zoo_application_type');
        //$textfield = $this->params->get('zoo_articletext_field', '');

        $item = new RokSprocket_Item();

        $item->setProvider($this->provider_name);
        $item->setId($raw_item->id);
        $item->setAlias(($raw_item->created_by_alias) ? $raw_item->created_by_alias : $raw_item->author_name);
        $item->setAuthor($raw_item->author_name);
        $item->setTitle($raw_item->title);
        $item->setDate($raw_item->created);
        $item->setPublished(($raw_item->published == 1) ? true : false);
        $item->setCategory($raw_item->category_title);
        $item->setHits($raw_item->hits);
        $item->setRating($raw_item->rating);
        $item->setMetaKey('');
        $item->setMetaDesc('');
        $item->setMetaData('');

        require_once(JPATH_ADMINISTRATOR . '/components/com_zoo/config.php');

        $app = App::getInstance('zoo');
        $applications = $app->application->getApplications();
        $application = $applications[$raw_item->application_id];
        $text_ids = array();
        $image_ids = array();
        $link_ids = array();
        $types = $application->getTypes();
        foreach ($types as $type) {
            $elements = $type->getElements();
            foreach ($elements as $element) {
                if ($element->config->type == 'image' || $element->config->type == 'jbimage') {
                    $image_ids[] = $element->identifier;
                }
                if ($element->config->type == 'link') {
                    $link_ids[] = $element->identifier;
                }
                if ($element->config->type == 'textarea' || $element->config->type == 'text') {
                    $text_ids[] = $element->identifier;
                }
            }
        }

        $els = json_decode($raw_item->elements);
        $texts = array();
        $images = array();
        $links = array();
        foreach ($els as $ident => $el) {
            if (in_array($ident, $image_ids)) {
                $image = new RokSprocket_Item_Image();
                 if($element->config->type == 'jbimage'){
                      $el = $el->{0};
                }
                $image->setSource($el->file);
                 $image->setIdentifier('image_field_' . $ident);
                $image->setCaption((isset($el->title))?$el->title:'');
                $image->setAlttext((isset($el->title))?$el->title:'');
                $images[$image->getIdentifier()] = $image;
                if (isset($images['image_field_' . $ident]) && !$item->getPrimaryImage()) {
                    $item->setPrimaryImage($image);
                }
            }

            if (in_array($ident, $link_ids)) {
                $link = new RokSprocket_Item_Link();
                $link->setUrl((isset($el->url))?$el->url:((isset($el->value))?$el->value:''));
                $link->setText('');
                $link->setIdentifier('link_field_' . $ident);
                $links[$link->getIdentifier()] = $link;
                if (isset($links['link_field_' . $ident]) && !$item->getPrimaryLink()) {
                    $item->setPrimaryLink($link);
                }
            }

            if (in_array($ident, $text_ids) && is_object($el)) {
                foreach ($el as $val){
                    $texts['text_field_' . $ident] = $val->value;
                }
            }
            else if (in_array($ident, $text_ids) && !is_object($el)){
                    $texts['text_field_' . $ident] = $el->value;
            }
        }
	    $item->setImages($images);
        $item->setLinks($links);

        $params = RokCommon_JSON::decode($raw_item->params);
        $desc = "metadata.description";
        $texts['text_field_metadesc'] = $params->$desc;
        $texts = $this->processPlugins($texts);
        $item->setTextFields($texts);
        $text = array_values($texts);
        $text = array_shift($text);
        $item->setText($text);


        $primary_link = new RokSprocket_Item_Link();
        $primary_link->setUrl(JRoute::_('index.php?option=com_zoo&task=item&item_id=' . $raw_item->id, true));
        $primary_link->getIdentifier('article_link');

        $item->setPrimaryLink($primary_link);

        $item->setCommentCount($raw_item->comment_count);
        $tags = (explode(',', $raw_item->tags)) ? explode(',', $raw_item->tags) : array();
        $item->setTags($tags);

        $item->setDbOrder($dborder);

        return $item;
    }

    /**
     * @param      $id
     *
     * @param bool $raw return the raw object not the RokSprocket_Item
     *
     * @return stdClass|RokSprocket_Item
     * @throws RokSprocket_Exception
     */
    public function getArticleInfo($id, $raw = false)
    {
        /** @var $filer_processor RokCommon_Filter_IProcessor */
        $filer_processor = $this->getFilterProcessor();
        $filer_processor->process(array('id' => array($id)));
        $query = $filer_processor->getQuery();
        $db = JFactory::getDbo();
        $db->setQuery($query);
	    $ret = $db->loadObject();
        if ($error = $db->getErrorMsg()) {
            throw new RokSprocket_Exception($error);
        }
        if ($raw) {
            $ret->preview = $this->_cleanPreview($ret->articletext);
            $ret->editUrl = $this->getArticleEditUrl($id);
            return $ret;
        } else {
            $item = $this->convertRawToItem($ret);
            $item->editUrl = $this->getArticleEditUrl($id);
            $item->preview = $this->_cleanPreview($item->getText());
            return $item;
        }
    }

    /**
     * @param $id
     *
     * @return string
     */
    protected function getArticleEditUrl($id)
    {
        return JURI::root(true) . '/administrator/index.php?option=com_zoo&controller=item&changeapp=1&task=edit&cid[]=' . $id;
    }

    /**
     * @return array the array of image type and label
     */
    public static function getImageTypes()
    {
        require_once(JPATH_ADMINISTRATOR . '/components/com_zoo/config.php');

        $app = App::getInstance('zoo');
        $applications = $app->application->getApplications();
        $list = array();
        foreach ($applications as $application) {
            $types = $application->getTypes();
            foreach ($types as $type) {
                $elements = $type->getElements();
                foreach ($elements as $element) {
                    if ($element->config->type == 'image' || $element->config->type == 'jbimage') {
                        $key = 'image_field_' . $element->identifier;
                        $list[$key] = array();
                        $list[$key]['group'] = $application->id . '_' . $type->id;
                        $list[$key]['display'] = $element->config->name;
                    }
                }
            }
        }
        return $list;
    }

    /**
     * @return array the array of link types and label
     */
    public static function getLinkTypes()
    {
        require_once(JPATH_ADMINISTRATOR . '/components/com_zoo/config.php');

        $app = App::getInstance('zoo');
        $applications = $app->application->getApplications();
        $list = array();
        foreach ($applications as $application) {
            $types = $application->getTypes();
            foreach ($types as $type) {
                $elements = $type->getElements();
                foreach ($elements as $element) {
                    if ($element->config->type == 'link') {
                        $key = 'link_field_' . $element->identifier;
                        $list[$key] = array();
                        $list[$key]['group'] = $application->id . '_' . $type->id;
                        $list[$key]['display'] = $element->config->name;
                    }
                }
            }
        }
        return $list;
    }

    /**
     * @return array the array of link types and label
     */
    public static function getTextTypes()
    {
        require_once(JPATH_ADMINISTRATOR . '/components/com_zoo/config.php');
        $app = App::getInstance('zoo');
        $applications = $app->application->getApplications();
        $list = array();
        foreach ($applications as $application) {
            $types = $application->getTypes();
            foreach ($types as $type) {
                $elements = $type->getElements();
                foreach ($elements as $element) {
                    if ($element->config->type == 'textarea' || $element->config->type == 'text') {
                        $key = 'text_field_' . $element->identifier;
                        $list[$key] = array();
                        $list[$key]['group'] = $application->id . '_' . $type->id;
                        $list[$key]['display'] = $element->config->name;
                    }
                }
            }
        }
        $static = array(
            'text_field_metadesc' => array('group' => null, 'display' => 'Meta Description Text'),
        );
        $list = array_merge($static, $list);
        return $list;
    }

    /**
     * @static
     * @return array
     */
    public static function getCCKGroups()
    {
        require_once(JPATH_ADMINISTRATOR . '/components/com_zoo/config.php');
        $app = App::getInstance('zoo');
        $applications = $app->application->getApplications();
        $list = array();
        foreach ($applications as $application) {
            $types = $application->getTypes();
            foreach ($types as $type) {
                $list[$application->id . '_' . $type->id] = $application->name . ' - ' . $type->name;
            }
        }
        return $list;
    }
}

Thanks for JBZoo team for the support and thanks for RocketTheme team for nice and clear code in RokSprocket module.






Click to return to top of page in style!