Ejemplo n.º 1
0
 /**
  * insert a new item in the database
  *
  * @param object $item reference to the {@link SmartsectionItem} object
  * @param bool $force
  * @return bool FALSE if failed, TRUE if already present and unchanged or successful
  */
 function insert(&$item, $force = false)
 {
     if (strtolower(get_class($item)) != 'smartsectionitem') {
         $item->setErrors('Invalid class provided.');
         return false;
     }
     if (!$item->meta_keywords() || !$item->meta_description() || !$item->short_url()) {
         $smartobject_metagen = new SmartsectionMetagen($item->title(), $item->getVar('meta_keywords'), $item->getVar('summary'));
         // Auto create meta tags if empty
         if (!$item->meta_keywords()) {
             $item->setVar('meta_keywords', $smartobject_metagen->_keywords);
         }
         if (!$item->meta_description()) {
             $item->setVar('meta_description', $smartobject_metagen->_description);
         }
         // Auto create short_url if empty
         if (!$item->short_url()) {
             $item->setVar('short_url', $smartobject_metagen->generateSeoTitle($item->getVar('title', 'n'), false));
         }
     }
     if (!$item->isDirty()) {
         return true;
     }
     if (!$item->cleanVars()) {
         $item->setErrors('Variables were not cleaned properly.');
         return false;
     }
     foreach ($item->cleanVars as $k => $v) {
         ${$k} = $v;
     }
     if ($item->isNew()) {
         $sql = sprintf("INSERT INTO %s (itemid,\n\t\t\tcategoryid,\n\t\t\ttitle,\n\t\t\tsummary,\n\t\t\tdisplay_summary,\n\t\t\tbody,\n\t\t\tuid,\n\t\t\tdatesub,\n\t\t\t`status`,\n\t\t\timage,\n\t\t\titem_tag,\n\t\t\tcounter,\n\t\t\tweight,\n\t\t\tpartial_view,\n\t\t\tdohtml,\n\t\t\tdosmiley,\n\t\t\tdoxcode,\n\t\t\tdoimage,\n\t\t\tdobr,\n\t\t\tcancomment,\n\t\t\tcomments,\n\t\t\tnotifypub,\n\t\t\tmeta_keywords,\n\t\t\tmeta_description,\n\t\t\tshort_url\n\t\t\t)\n\t\t\tVALUES (NULL,\n\t\t\t%u,\n\t\t\t%s,\n\t\t\t%s,\n\t\t\t%u,\n\t\t\t%s,\n\t\t\t%u,\n\t\t\t%u,\n\t\t\t%u,\n\t\t\t%s,\n\t\t\t%s,\n\t\t\t%s,\n\t\t\t%u,\n\t\t\t%u,\n\t\t\t%s,\n\t\t\t%u,\n\t\t\t%u,\n\t\t\t%u,\n\t\t\t%u,\n\t\t\t%u,\n\t\t\t%u,\n\t\t\t%u,\n\t\t\t%s,\n\t\t\t%s,\n\t\t\t%s\n\t\t\t)", $this->db->prefix('smartsection_items'), $categoryid, $this->db->quoteString($title), $this->db->quoteString($summary), $display_summary, $this->db->quoteString($body), $uid, $datesub, $status, $this->db->quoteString($image), $this->db->quoteString($item_tag), $counter, $weight, $this->db->quoteString($partial_view), $dohtml, $dosmiley, $doxcode, $doimage, $dobr, $cancomment, $comments, $notifypub, $this->db->quoteString($meta_keywords), $this->db->quoteString($meta_description), $this->db->quoteString($short_url));
     } else {
         $sql = sprintf("UPDATE %s\n\t\t\tSET categoryid = %u,\n\t\t\ttitle = %s,\n\t\t\tsummary = %s,\n\t\t\tdisplay_summary = %u,\n\t\t\tbody = %s,\n\t\t\tuid = %u,\n\t\t\tdatesub = %u,\n\t\t\t`status` = %u,\n\t\t\timage = %s,\n\t\t\titem_tag = %s,\n\t\t\tcounter = %u,\n\t\t\tweight = %u,\n\t\t\tpartial_view = %s,\n\t\t\tdohtml = %u,\n\t\t\tdosmiley = %u,\n\t\t\tdoxcode = %u,\n\t\t\tdoimage = %u,\n\t\t\tdobr = %u,\n\t\t\tcancomment = %u,\n\t\t\tcomments = %u,\n\t\t\tnotifypub = %u,\n\t\t\tmeta_keywords = %s,\n\t\t\tmeta_description = %s,\n\t\t\tshort_url = %s\n\t\t\tWHERE itemid = %u", $this->db->prefix('smartsection_items'), $categoryid, $this->db->quoteString($title), $this->db->quoteString($summary), $display_summary, $this->db->quoteString($body), $uid, $datesub, $status, $this->db->quoteString($image), $this->db->quoteString($item_tag), $counter, $weight, $this->db->quoteString($partial_view), $dohtml, $dosmiley, $doxcode, $doimage, $dobr, $cancomment, $comments, $notifypub, $this->db->quoteString($meta_keywords), $this->db->quoteString($meta_description), $this->db->quoteString($short_url), $itemid);
     }
     //echo "<br />" . $sql . "<br />";exit;
     if (false != $force) {
         $result = $this->db->queryF($sql);
     } else {
         $result = $this->db->query($sql);
     }
     if (!$result) {
         $item->setErrors('The query returned an error. ' . $this->db->error());
         return false;
     }
     if ($item->isNew()) {
         $item->assignVar('itemid', $this->db->getInsertId());
     }
     if (smartsection_tag_module_included()) {
         // Storing tags information
         $tag_handler = xoops_getmodulehandler('tag', 'tag');
         $tag_handler->updateByItem($item_tag, $item->getVar('itemid'), 'smartsection', 0);
     }
     // Saving permissions
     smartsection_saveItemPermissions($item->getGroups_read(), $item->itemid());
     return true;
 }
Ejemplo n.º 2
0
$xoopsTpl->assign('next_item_link', $next_item_link);
$xoopsTpl->assign('previous_item_url', $previous_item_url);
$xoopsTpl->assign('next_item_url', $next_item_url);
$xoopsTpl->assign('other_items', $xoopsModuleConfig['other_items_type']);
$itemFooter = smartsection_getConfig('itemfooter');
$itemFooter = $myts->displayTarea($itemFooter);
$xoopsTpl->assign('itemfooter', $itemFooter);
// tags support
if (smartsection_tag_module_included()) {
    include_once XOOPS_ROOT_PATH . "/modules/tag/include/tagbar.php";
    $xoopsTpl->assign('tagbar', tagBar($itemid, $catid = 0));
}
/**
 * Generating meta information for this page
 */
$smartsection_metagen = new SmartsectionMetagen($itemObj->getVar('title'), $itemObj->getVar('meta_keywords', 'n'), $itemObj->getVar('meta_description', 'n'), $itemObj->getCategoryPath());
$smartsection_metagen->createMetaTags();
//SmartObject Rating feature
if (file_exists(XOOPS_ROOT_PATH . '/modules/smartobject/include/rating.rate.php')) {
    include_once XOOPS_ROOT_PATH . '/modules/smartobject/include/rating.rate.php';
}
// Include the comments if the selected ITEM supports comments
if ($itemObj->cancomment() == 1 || !$xoopsModuleConfig['commentatarticlelevel'] && smartsection_getConfig('com_rule') != 0) {
    include_once XOOPS_ROOT_PATH . "/include/comment_view.php";
    // Problem with url_rewrite and posting comments :
    $xoopsTpl->assign(array('editcomment_link' => SMARTSECTION_URL . 'comment_edit.php?com_itemid=' . $com_itemid . '&amp;com_order=' . $com_order . '&amp;com_mode=' . $com_mode . '' . $link_extra, 'deletecomment_link' => SMARTSECTION_URL . 'comment_delete.php?com_itemid=' . $com_itemid . '&amp;com_order=' . $com_order . '&amp;com_mode=' . $com_mode . '' . $link_extra, 'replycomment_link' => SMARTSECTION_URL . 'comment_reply.php?com_itemid=' . $com_itemid . '&amp;com_order=' . $com_order . '&amp;com_mode=' . $com_mode . '' . $link_extra));
    $xoopsTpl->_tpl_vars['commentsnav'] = str_replace("self.location.href='", "self.location.href='" . SMARTSECTION_URL, $xoopsTpl->_tpl_vars['commentsnav']);
}
$xoopsTpl->assign('rating_enabled', $xoopsModuleConfig['rating_enabled']);
$newGroupsArray = array();
$newGroupsArray[0] = 'None';
Ejemplo n.º 3
0
 /**
  * insert a new category in the database
  *
  * @param object $category reference to the {@link SmartsectionCategory} object
  * @param bool $force
  * @return bool FALSE if failed, TRUE if already present and unchanged or successful
  */
 function insert(&$category, $force = false)
 {
     if (strtolower(get_class($category)) != 'smartsectioncategory') {
         return false;
     }
     // Auto create meta tags if empty
     if (!$category->meta_keywords() || !$category->meta_description()) {
         $smartobject_metagen = new SmartsectionMetagen($category->name(), $category->getVar('meta_keywords'), $category->getVar('description'));
         if (!$category->meta_keywords()) {
             $category->setVar('meta_keywords', $smartobject_metagen->_keywords);
         }
         if (!$category->meta_description()) {
             $category->setVar('meta_description', $smartobject_metagen->_description);
         }
     }
     // Auto create short_url if empty
     if (!$category->short_url()) {
         $category->setVar('short_url', $smartobject_metagen->generateSeoTitle($category->name('n'), false));
     }
     if (!$category->isDirty()) {
         return true;
     }
     if (!$category->cleanVars()) {
         return false;
     }
     foreach ($category->cleanVars as $k => $v) {
         ${$k} = $v;
     }
     if ($category->isNew()) {
         $sql = sprintf("INSERT INTO %s (\n\t\t\t\t\t\t\t\tcategoryid,\n\t\t\t\t\t\t\t\tparentid,\n\t\t\t\t\t\t\t\tname,\n\t\t\t\t\t\t\t\tdescription,\n\t\t\t\t\t\t\t\timage,\n\t\t\t\t\t\t\t\ttotal,\n\t\t\t\t\t\t\t\tweight,\n\t\t\t\t\t\t\t\tcreated,\n\t\t\t\t\t\t\t\ttemplate,\n\t\t\t\t\t\t\t\theader,\n\t\t\t\t\t\t\t\tmeta_keywords,\n\t\t\t\t\t\t\t\tmeta_description,\n\t\t\t\t\t\t\t\tshort_url\n\t\t\t\t\t\t\t) VALUES (\n\t\t\t\t\t\t\t\tNULL,\n\t\t\t\t\t\t\t\t%u,\n\t\t\t\t\t\t\t\t%s,\n\t\t\t\t\t\t\t\t%s,\n\t\t\t\t\t\t\t\t%s,\n\t\t\t\t\t\t\t\t%u,\n\t\t\t\t\t\t\t\t%u,\n\t\t\t\t\t\t\t\t%u,\n\t\t\t\t\t\t\t\t%s,\n\t\t\t\t\t\t\t\t%s,\n\t\t\t\t\t\t\t\t%s,\n\t\t\t\t\t\t\t\t%s,\n\t\t\t\t\t\t\t\t%s\n\t\t\t\t\t\t\t)", $this->db->prefix('smartsection_categories'), $parentid, $this->db->quoteString($name), $this->db->quoteString($description), $this->db->quoteString($image), $total, $weight, time(), $this->db->quoteString($template), $this->db->quoteString($header), $this->db->quoteString($meta_keywords), $this->db->quoteString($meta_description), $this->db->quoteString($short_url));
     } else {
         $sql = sprintf("UPDATE %s SET\n\t\t\t\t\t\t\t\tparentid = %u,\n\t\t\t\t\t\t\t\tname = %s,\n\t\t\t\t\t\t\t\tdescription = %s,\n\t\t\t\t\t\t\t\timage = %s,\n\t\t\t\t\t\t\t\ttotal = %s,\n\t\t\t\t\t\t\t\tweight = %u,\n\t\t\t\t\t\t\t\tcreated = %u,\n\t\t\t\t\t\t\t\ttemplate = %s ,\n\t\t\t\t\t\t\t\theader = %s,\n\t\t\t\t\t\t\t\tmeta_keywords = %s,\n\t\t\t\t\t\t\t\tmeta_description = %s,\n\t\t\t\t\t\t\t\tshort_url = %s\n\t\t\t\t\t\t\tWHERE categoryid = %u", $this->db->prefix('smartsection_categories'), $parentid, $this->db->quoteString($name), $this->db->quoteString($description), $this->db->quoteString($image), $total, $weight, $created, $this->db->quoteString($template), $this->db->quoteString($header), $this->db->quoteString($meta_keywords), $this->db->quoteString($meta_description), $this->db->quoteString($short_url), $categoryid);
     }
     //echo "<br />" . $sql . "<br />";
     if (false != $force) {
         $result = $this->db->queryF($sql);
     } else {
         $result = $this->db->query($sql);
     }
     if (!$result) {
         $category->setErrors('The query returned an error. ' . $this->db->error());
         return false;
     }
     if ($category->isNew()) {
         $category->assignVar('categoryid', $this->db->getInsertId());
     }
     $category->assignVar('categoryid', $categoryid);
     return true;
 }