Example #1
0
 /**
  * Render comments and respond form html.
  *
  * @param AppView $view The view the comments are rendered on
  * @param Item $item The item whos comments are rendered
  *
  * @return string The html output
  *
  * @since 2.0
  */
 public function renderComments($view, $item)
 {
     if ($item->getApplication()->isCommentsEnabled()) {
         // get application params
         $params = $this->app->parameter->create($item->getApplication()->getParams()->get('global.comments.'));
         if ($params->get('twitter_enable') && !function_exists('curl_init')) {
             $this->app->error->raiseWarning(500, JText::_('To use Twitter, CURL needs to be enabled in your php settings.'));
             $params->set('twitter_enable', false);
         }
         // get active author
         $active_author = $this->activeAuthor();
         // get comment content from session
         $content = $this->app->system->session->get('com_zoo.comment.content');
         $params->set('content', $content);
         // get comments and build tree
         $approved = $item->canManageComments() ? Comment::STATE_UNAPPROVED : Comment::STATE_APPROVED;
         $comments = $item->getCommentTree($approved);
         // build captcha
         $captcha = false;
         if ($plugin = $params->get('captcha', false) and (!$params->get('captcha_guest_only', 0) or !$this->app->user->get()->id)) {
             $captcha = JCaptcha::getInstance($plugin);
         }
         if ($item->isCommentsEnabled() || count($comments) - 1) {
             // create comments html
             return $view->partial('comments', compact('item', 'active_author', 'comments', 'params', 'captcha'));
         }
     }
     return null;
 }
Example #2
0
 /**
  * Get align for media position for item
  * @param Item   $item
  * @param string $layout
  * @return string
  */
 public function getMediaAlign(Item $item, $layout)
 {
     $paramName = str_replace('.' . $item->type . '.', '.', $layout);
     $paramName = str_replace('.', '_', $paramName);
     $paramName = 'template.' . $paramName . '_image_align';
     $align = $item->params->get($paramName, false);
     if ($align === false) {
         $align = $item->getApplication()->params->get('global.' . $paramName, $this->_defaultAlign);
     }
     return $align;
 }
Example #3
0
 /**
  * Send notification email
  *
  * @param Item $item Item
  * @param array $recipients Array email => name
  * @param string $layout The layout
  *
  * @since 2.0
  */
 public function sendNotificationMail($item, $recipients, $layout)
 {
     // workaround to make sure JSite is loaded
     $this->app->loader->register('JSite', 'root:includes/application.php');
     // init vars
     $website_name = $this->app->system->config->get('sitename');
     $item_link = JURI::root() . 'administrator/index.php?' . http_build_query(array('option' => $this->app->component->self->name, 'controller' => 'item', 'changeapp' => $item->application_id, 'task' => 'edit', 'cid[]' => $item->id), '', '&');
     // send email to $recipients
     foreach ($recipients as $email => $name) {
         if (empty($email)) {
             continue;
         }
         $mail = $this->app->mail->create();
         $mail->setSubject(JText::_("New Submission notification") . " - " . $item->name);
         $mail->setBodyFromTemplate($item->getApplication()->getTemplate()->resource . $layout, compact('item', 'submission', 'website_name', 'email', 'name', 'item_link'));
         $mail->addRecipient($email);
         $mail->Send();
     }
 }
 /**
  * Update JBZoo index by itemId
  * @param Item $item
  * @param bool $returnDataPack
  * @return int|array
  */
 public function updateByItem(Item $item, $returnDataPack = false)
 {
     if ($item->getApplication()->getGroup() != JBZOO_APP_GROUP) {
         return null;
     }
     // for corrupted database
     if (!$item->getType()) {
         return 0;
     }
     $this->removeById($item);
     $itemPack = array('item_id' => $item->id, 'max_deep' => 0, 'data' => array());
     $rows = $this->_parseStdData($item);
     $elements = $item->getElements();
     foreach ($elements as $element) {
         $rows[$element->identifier] = $element->getSearchData();
     }
     foreach ($rows as $elementId => $row) {
         $rowData = $this->_valuesByTypes($row, $elementId);
         // find max deep vars level
         if (!empty($rowData)) {
             $max = max(count($rowData['s']), count($rowData['n']), count($rowData['d']));
             if ($itemPack['max_deep'] < $max) {
                 $itemPack['max_deep'] = $max;
             }
         }
         // compact values from field types
         foreach ($rowData as $keyType => $values) {
             $clearElemId = $this->app->jbtables->getFieldName($elementId, $keyType);
             if (!empty($values)) {
                 $itemPack['data'][$clearElemId] = $values;
             }
         }
     }
     if ($returnDataPack) {
         return $itemPack;
     }
     $itemType = $item->getType()->id;
     $result = array($itemType => array($itemPack));
     $skuPack = $this->_getSkuData($item);
     if (!empty($skuPack)) {
         $this->_multiInsert($skuPack, ZOO_TABLE_JBZOO_SKU);
     }
     return $this->_multiInsertData($result);
 }
Example #5
0
 /**
  * Get duration element from item, using mapping
  *
  * @param   Item    $item
  * @param   string  Subscription property name, that you wish to get (e.g. duration, etc.)
  * @return  mixed
  */
 public function getSubscriptionElements($item)
 {
     $duration = array();
     if (!empty($item)) {
         $config = array();
         $config[] = $item->getApplication()->application_group;
         $config[] = $item->type;
         $config[] = 'subscription';
         $renderer = $this->app->renderer->create('item')->addPath(array($this->app->path->path("zoocart:mapping")));
         $subs_config = $renderer->getConfig('item')->get(implode('.', $config));
         if (!empty($subs_config)) {
             foreach ($subs_config as $property => $elements) {
                 // Get first element from each position:
                 $element = @array_shift($elements);
                 if ($element) {
                     $duration[$property] = $item->getElement($element['element']);
                 }
             }
         }
     }
     return $duration;
 }