Exemplo n.º 1
0
 public function render($params = array())
 {
     if (!empty($this->_item)) {
         $params = new YArray($params);
         if ($params->get('link_to_item', false) && $this->_item->getState()) {
             $url = RouteHelper::getItemRoute($this->_item);
             return '<a title="' . $this->_item->name . '" href="' . JRoute::_($url) . '">' . $this->_item->name . '</a>';
         } else {
             return $this->_item->name;
         }
     }
 }
Exemplo n.º 2
0
 public function render($params = array())
 {
     $params = new YArray($params);
     // include assets css
     JHTML::stylesheet('itemprint.css', 'administrator/components/com_zoo/elements/itemprint/assets/css/');
     if (YRequest::getBool('print', 0)) {
         return '<a class="element-print-button" onclick="window.print();return false;" href="#"></a>';
     } else {
         JHTML::_('behavior.modal', 'a.modal');
         $text = $params->get('showicon') ? '' : JText::_('Print');
         $class = $params->get('showicon') ? 'modal element-print-button' : 'modal';
         return '<a href="' . JRoute::_(RouteHelper::getItemRoute($this->_item) . '&amp;tmpl=component&amp;print=1') . '" title="' . JText::_('Print') . '" rel="{handler: \'iframe\', size: {x: 850, y: 500}}" class="' . $class . '">' . $text . '</a>';
     }
 }
Exemplo n.º 3
0
 public function render($params)
 {
     // init vars
     $params = new YArray($params);
     $height = $params->get('height');
     $width = $params->get('width');
     $enabled = $this->_data->get('value');
     // render html
     if ($width && $height && $enabled) {
         $permalink = urlencode(JRoute::_(RouteHelper::getItemRoute($this->_item), true, -1));
         $href = 'http://www.facebook.com/plugins/like.php?href=' . $permalink . '&amp;layout=standard&amp;show_faces=false&amp;width=300&amp;action=like&amp;colorscheme=light&amp;height=' . $height;
         $html = '<iframe src="' . $href . '" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width: ' . $width . 'px; height: ' . $height . 'px;" ></iframe>';
         return $html;
     }
     return null;
 }
Exemplo n.º 4
0
 public function render($params = array())
 {
     // init vars
     $params = new YArray($params);
     $items = array();
     $output = array();
     $layout_path = $params->get('layout_path');
     $renderer = new ItemRenderer();
     $renderer->addPath($layout_path);
     $layout = $params->get('layout');
     $items = $this->_getRelatedItems();
     // sort items
     $order = $params->get('order');
     if (in_array($order, array('alpha', 'ralpha'))) {
         usort($items, create_function('$a,$b', 'return strcmp($a->name, $b->name);'));
     } elseif (in_array($order, array('date', 'rdate'))) {
         usort($items, create_function('$a,$b', 'return (strtotime($a->created) == strtotime($b->created)) ? 0 : (strtotime($a->created) < strtotime($b->created)) ? -1 : 1;'));
     } elseif (in_array($order, array('hits', 'rhits'))) {
         usort($items, create_function('$a,$b', 'return ($a->hits == $b->hits) ? 0 : ($a->hits < $b->hits) ? -1 : 1;'));
     } elseif ($order == 'random') {
         shuffle($items);
     } else {
     }
     if (in_array($order, array('ralpha', 'rdate', 'rhits'))) {
         $items = array_reverse($items);
     }
     // create output
     foreach ($items as $item) {
         $path = 'item';
         $prefix = 'item.';
         $type = $item->getType()->id;
         if ($renderer->pathExists($path . DIRECTORY_SEPARATOR . $type)) {
             $path .= DIRECTORY_SEPARATOR . $type;
             $prefix .= $type . '.';
         }
         if (in_array($layout, $renderer->getLayouts($path))) {
             $output[] = $renderer->render($prefix . $layout, array('item' => $item));
         } elseif ($params->get('link_to_item', false) && $item->getState()) {
             $url = RouteHelper::getItemRoute($item);
             $output[] = '<a href="' . JRoute::_($url) . '" title="' . $item->name . '">' . $item->name . '</a>';
         } else {
             $output[] = $item->name;
         }
     }
     return ElementHelper::applySeparators($params->get('separated_by'), $output);
 }
Exemplo n.º 5
0
 public function _renderSubmission($params = array())
 {
     // get params
     $params = new YArray($params);
     $trusted_mode = $params->get('trusted_mode');
     if ($layout = $this->getLayout('submission.php')) {
         return self::renderLayout($layout, array('element' => $this->identifier, 'index' => $this->index(), 'text' => $this->_data->get('text'), 'link' => $this->_data->get('value'), 'target' => $this->_data->get('target'), 'title' => $this->_data->get('custom_title'), 'rel' => $this->_data->get('rel'), 'trusted_mode' => $trusted_mode));
     }
 }
Exemplo n.º 6
0
 public function _renderSubmission($params = array())
 {
     // get params
     $params = new YArray($params);
     $trusted_mode = $params->get('trusted_mode');
     if ($layout = $this->getLayout('submission.php')) {
         return self::renderLayout($layout, array('element' => $this->identifier, 'index' => $this->index(), 'text' => $this->_data->get('text'), 'email' => $this->_data->get('value'), 'subject' => $this->_data->get('subject', ''), 'body' => $this->_data->get('body', ''), 'trusted_mode' => $trusted_mode));
     }
 }
Exemplo n.º 7
0
 protected function _renderRepeatable($params = array())
 {
     $params = new YArray($params);
     $trusted_mode = $params->get('trusted_mode', false);
     if ($repeatable = $this->_config->get('repeatable')) {
         // create repeat-elements
         $html = array();
         $html[] = '<div id="' . $this->identifier . '" class="repeat-elements">';
         $html[] = '<ul class="repeatable-list">';
         foreach ($this as $self) {
             $html[] = '<li class="repeatable-element">';
             $html[] = $self->_addEditor($this->index(), $this->_data->get('value'), $trusted_mode);
             $html[] = '</li>';
         }
         for ($index = count($this->_data_array); $index < count($this->_data_array) + self::MAX_HIDDEN_EDITORS; $index++) {
             $html[] = '<li class="repeatable-element hidden">';
             $html[] = $this->_addEditor($index, '', $trusted_mode);
             $html[] = '</li>';
         }
         $html[] = '</ul>';
         $html[] = '<p class="add"><a href="javascript:void(0);">' . JText::sprintf('Add another %s', JString::ucfirst($this->getElementType())) . '</a></p>';
         $html[] = '</div>';
         // create js
         $javascript = "jQuery('#{$this->identifier}').ElementRepeatableTextarea({ msgDeleteElement : '" . JText::_('Delete Element') . "' });";
         $javascript = "<script type=\"text/javascript\">\n//<!--\n{$javascript}\n// -->\n</script>\n";
         return implode("\n", $html) . $javascript;
     } else {
         return $this->_addEditor(0, $this->_data->get('value'), $trusted_mode);
     }
 }
Exemplo n.º 8
0
 public function render($params = array())
 {
     // init vars
     $location = $this->_data->get('location');
     $locale = $this->_config->get('locale');
     // init display params
     $params = new YArray($params);
     $layout_path = $params->get('layout_path');
     $layout = $params->get('layout');
     $width = $params->get('width');
     $width_unit = $params->get('width_unit');
     $height = $params->get('height');
     $marker_popup = $params->get('marker_popup');
     $zoom_level = $params->get('zoom_level');
     $map_controls = $params->get('map_controls');
     $scroll_wheel_zoom = $params->get('scroll_wheel_zoom');
     $map_type = $params->get('map_type');
     $map_controls = $params->get('map_controls');
     $type_controls = $params->get('type_controls');
     $directions = $params->get('directions');
     $main_icon = $params->get('main_icon');
     $information = $params->get('information');
     // determine locale
     if (empty($locale) || $locale == 'auto') {
         $locale = UserHelper::getBrowserDefaultLanguage();
     }
     // get marker text
     $marker_text = '';
     $renderer = new ItemRenderer();
     $renderer->addPath($layout_path);
     if ($item = $this->getItem()) {
         $path = 'item';
         $prefix = 'item.';
         $type = $item->getType()->id;
         if ($renderer->pathExists($path . DIRECTORY_SEPARATOR . $type)) {
             $path .= DIRECTORY_SEPARATOR . $type;
             $prefix .= $type . '.';
         }
         if (in_array($layout, $renderer->getLayouts($path))) {
             $marker_text = $renderer->render($prefix . $layout, array('item' => $item));
         } else {
             $marker_text = $item->name;
         }
     }
     // get geocode cache
     $cache = new YCache(ZOO_CACHE_PATH . DS . 'geocode_cache.txt');
     if (!$cache->check()) {
         return "<div class=\"alert\"><strong>Cache not writeable please update the file permissions! (geocode_cache.txt)</strong></div>\n";
     }
     // get map center coordinates
     $center = GooglemapsHelper::locate($location, $cache);
     if (!$center) {
         return "<div class=\"alert\"><strong>Unable to get map center coordinates, please verify your location! (" . $location . ")</strong></div>\n";
     }
     // save location to geocode cache
     if ($cache) {
         $cache->save();
     }
     // css parameters
     $maps_id = 'googlemaps-' . $this->_item->id;
     $css_module_width = 'width: ' . $width . $width_unit . ';';
     $css_module_height = 'height: ' . $height . 'px;';
     $from_address = JText::_('From address:');
     $get_directions = JText::_('Get directions');
     $empty = JText::_('Please fill in your address.');
     $not_found = JText::_('Sorry, address not found!');
     $address_not_found = ', ' . JText::_('not found!');
     // js parameters
     $javascript = "\$('#{$maps_id}').Googlemaps({ lat:" . $center['lat'] . ", lng:" . $center['lng'] . ", popup: " . $marker_popup . ", text: '" . GooglemapsHelper::stripText($marker_text) . "', zoom: " . $zoom_level . ", mapCtrl: " . $map_controls . ", zoomWhl: " . $scroll_wheel_zoom . ", mapType: " . $map_type . ", typeCtrl: " . $type_controls . ", directions: " . $directions . ", locale: '" . $locale . "', mainIcon:'" . $main_icon . "', msgFromAddress: '" . $from_address . "', msgGetDirections: '" . $get_directions . "', msgEmpty: '" . $empty . "', msgNotFound: '" . $not_found . "', msgAddressNotFound: '" . $address_not_found . "' });";
     $javascript = "jQuery(function(\$) { {$javascript} });";
     // render layout
     if ($layout = $this->getLayout()) {
         return self::renderLayout($layout, array('maps_id' => $maps_id, 'javascript' => $javascript, 'css_module_width' => $css_module_width, 'css_module_height' => $css_module_height, 'information' => $information, 'locale' => $locale));
     }
     return null;
 }
Exemplo n.º 9
0
 public function renderSubmission($params = array())
 {
     // load js
     JHTML::script('image.js', 'administrator/components/com_zoo/elements/image/assets/js/');
     // init vars
     $image = $this->_data->get('file');
     // is uploaded file
     $image = is_array($image) ? '' : $image;
     // get params
     $params = new YArray($params);
     $trusted_mode = $params->get('trusted_mode');
     // build image select
     $lists = array();
     if ($trusted_mode) {
         $options = array(JHTML::_('select.option', '', '- ' . JText::_('Select Image') . ' -'));
         if (!empty($image) && !$this->_inUploadPath($image)) {
             $options[] = JHTML::_('select.option', $image, '- ' . JText::_('No Change') . ' -');
         }
         $img_ext = str_replace(',', '|', trim(JComponentHelper::getParams('com_media')->get('image_extensions'), ','));
         foreach (YFile::readDirectoryFiles(JPATH_ROOT . '/' . $this->_getUploadImagePath() . '/', $this->_getUploadImagePath() . '/', '/\\.(' . $img_ext . ')$/i', false) as $file) {
             $options[] = JHTML::_('select.option', $file, basename($file));
         }
         $lists['image_select'] = JHTML::_('select.genericlist', $options, 'elements[' . $this->identifier . '][image]', 'class="image"', 'value', 'text', $image);
     } else {
         if (!empty($image)) {
             $image = ZooHelper::resizeImage(JPATH_ROOT . DS . $image, 0, 0);
             $image = trim(str_replace('\\', '/', preg_replace('/^' . preg_quote(JPATH_ROOT, '/') . '/i', '', $image)), '/');
         }
     }
     if (!empty($image)) {
         $image = JURI::root() . $image;
     }
     if ($layout = $this->getLayout('submission.php')) {
         return self::renderLayout($layout, array('element' => $this->identifier, 'lists' => $lists, 'image' => $image));
     }
 }
Exemplo n.º 10
0
 private static function _importItems(Application $application, $items_xml_array = array(), $element_assignment = array(), $types = array())
 {
     // init vars
     $db = YDatabase::getInstance();
     $table = YTable::getInstance('item');
     $item_vars = array_keys(get_class_vars('Item'));
     $user_id = JFactory::getUser()->get('id');
     $app_types = $application->getTypes();
     $authors = new YArray(YDatabase::getInstance()->queryObjectList('SELECT id, username FROM #__users'));
     $items = array();
     foreach ($items_xml_array as $key => $items_xml) {
         $index = (string) $items_xml->attributes()->name;
         if (isset($types[$index]) && !empty($types[$index]) && ($type = $app_types[$types[$index]])) {
             $elements = $type->getElements();
             $traverse = true;
             while ($traverse) {
                 $traverse = false;
                 foreach ($items_xml->item as $item_xml) {
                     $traverse = true;
                     $item = new Item();
                     $item->old_alias = (string) $item_xml->attributes()->id;
                     $item->alias = YString::sluggify($item->old_alias);
                     $item->type = $type->id;
                     // set a valid category alias
                     while (ItemHelper::checkAliasExists($item->alias)) {
                         $item->alias .= '-2';
                     }
                     $db->query('INSERT INTO ' . ZOO_TABLE_ITEM . '(alias) VALUES (' . $db->quote($item->alias) . ')');
                     $item->id = $db->insertid();
                     // set item values
                     foreach ($item_xml->children() as $child) {
                         $name = $child->getName();
                         if (in_array($name, $item_vars)) {
                             $item->{$name} = (string) $child;
                         }
                     }
                     // store application id
                     $item->application_id = $application->id;
                     // store categories
                     $item->categories = array();
                     foreach ($item_xml->getElementsByPath('categories/category') as $category_xml) {
                         $item->categories[] = (string) $category_xml;
                     }
                     // store tags
                     $tags = array();
                     foreach ($item_xml->getElementsByPath('tags/tag') as $tag_xml) {
                         $tags[] = (string) $tag_xml;
                     }
                     $item->setTags($tags);
                     // store author
                     $item->created_by_alias = "";
                     if ($item_xml->author) {
                         $author = (string) $item_xml->author;
                         $key = $authors->searchRecursive($author);
                         if ($key !== false) {
                             $item->created_by = (int) $authors[$key]->id;
                         } else {
                             $item->created_by_alias = $author;
                         }
                     }
                     // if author is unknown set current user as author
                     if (!$item->created_by) {
                         $item->created_by = $user_id;
                     }
                     // store modified_by
                     $item->modified_by = $user_id;
                     // store element_data
                     if ($data = $item_xml->data) {
                         $elements_xml = YXMLElement::create('elements');
                         $nodes_to_delete = array();
                         foreach ($data->children() as $key => $element_xml) {
                             $old_element_alias = (string) $element_xml->attributes()->identifier;
                             if (isset($element_assignment[$index][$old_element_alias][$type->id]) && ($element_alias = $element_assignment[$index][$old_element_alias][$type->id])) {
                                 $element_xml->addAttribute('identifier', $element_alias);
                                 $elements_xml->appendChild($element_xml);
                             } else {
                                 $nodes_to_delete[] = $element_xml;
                             }
                         }
                         foreach ($nodes_to_delete as $node) {
                             $data->removeChild($node);
                         }
                         $item->elements = $elements_xml->asXML(true, true);
                     }
                     // store metadata
                     $params = $item->getParams();
                     if ($metadata = $item_xml->metadata) {
                         foreach ($metadata->children() as $metadata_xml) {
                             $params->set('metadata.' . $metadata_xml->getName(), (string) $metadata_xml);
                         }
                     }
                     $item->params = $params->toString();
                     $items[$item->old_alias] = $item;
                     $items_xml->removeChild($item_xml);
                 }
             }
         }
     }
     // sanatize relateditems elements
     foreach ($items as $key => $item) {
         foreach ($item->getElements() as $element) {
             if ($element->getElementType() == 'relateditems') {
                 $relateditems = $element->getElementData()->get('item', array());
                 $new_related_items = array();
                 foreach ($relateditems as $key => $relateditem) {
                     if (isset($items[$relateditem])) {
                         $new_related_items[] = $items[$relateditem]->id;
                     }
                 }
                 $element->getElementData()->set('item', $new_related_items);
             }
         }
         try {
             $table->save($item);
             $item->unsetElementData();
         } catch (YException $e) {
             JError::raiseNotice(0, JText::_('Error Importing Item') . ' (' . $e . ')');
         }
     }
     return $items;
 }
Exemplo n.º 11
0
<?php

/**
* @package   ZOO Component
* @file      block.php
* @version   2.3.0 December 2010
* @author    YOOtheme http://www.yootheme.com
* @copyright Copyright (C) 2007 - 2011 YOOtheme GmbH
* @license   http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 only
*/
// no direct access
defined('_JEXEC') or die('Restricted access');
$params = new YArray($params);
// add tooltip
$tooltip = '';
if ($params->get('show_tooltip') && ($description = $element->getConfig()->get('description'))) {
    $tooltip = ' class="hasTip" title="' . $description . '"';
}
// create label
$label = '<strong' . $tooltip . '>';
$label .= $params->get('altlabel') ? $params->get('altlabel') : $element->getConfig()->get('name');
$label .= '</strong>';
// create error
$error = '';
if ($field->hasError()) {
    $error = '<p class="error-message">' . (string) $field->getError() . '</p>';
}
// create class attribute
$class = 'element element-' . $element->getElementType() . ($params->get('first') ? ' first' : '') . ($params->get('last') ? ' last' : '') . ($params->get('required') ? ' required' : '') . ($field->hasError() ? ' error' : '');
$element->loadAssets();
?>
Exemplo n.º 12
0
 public function renderSubmission($params = array())
 {
     // get params
     $params = new YArray($params);
     $trusted_mode = $params->get('trusted_mode');
     // init vars
     $upload = $this->_data->get('file');
     $download_limit = $this->_data->get('download_limit');
     if (empty($upload) && $trusted_mode) {
         $upload = $this->_data->get('upload');
     }
     // is uploaded file
     $upload = is_array($upload) ? '' : $upload;
     // build upload select
     $lists = array();
     if ($trusted_mode) {
         $options = array(JHTML::_('select.option', '', '- ' . JText::_('Select File') . ' -'));
         if (!empty($upload) && !$this->_inUploadPath($upload)) {
             $options[] = JHTML::_('select.option', $upload, '- ' . JText::_('No Change') . ' -');
         }
         foreach (YFile::readDirectoryFiles(JPATH_ROOT . '/' . $this->_getUploadPath() . '/', $this->_getUploadPath() . '/', false, false) as $file) {
             $options[] = JHTML::_('select.option', $file, basename($file));
         }
         $lists['upload_select'] = JHTML::_('select.genericlist', $options, 'elements[' . $this->identifier . '][upload]', 'class="upload"', 'value', 'text', $upload);
     }
     if (!empty($upload)) {
         $upload = basename($upload);
     }
     if ($layout = $this->getLayout('submission.php')) {
         return self::renderLayout($layout, array('element' => $this->identifier, 'lists' => $lists, 'upload' => $upload, 'trusted_mode' => $trusted_mode, 'download_limit' => $download_limit));
     }
 }
Exemplo n.º 13
0
 public function renderSubmission($params = array())
 {
     // init vars
     $width = $this->_data->get('width');
     $height = $this->_data->get('height');
     $autoplay = $this->_data->get('autoplay', false);
     // get params
     $params = new YArray($params);
     $trusted_mode = $params->get('trusted_mode');
     if ($layout = $this->getLayout('submission.php')) {
         return self::renderLayout($layout, array('element' => $this->identifier, 'url' => $this->_data->get('url'), 'trusted_mode' => $trusted_mode, 'width' => $width, 'height' => $height, 'autoplay' => $autoplay));
     }
     return null;
 }