public function __construct($title, $keywords = false, $description = false, $categoryPath = false) { parent::__construct($title, $keywords, $description, $categoryPath); $this->_deprecated = icms_core_Debug::setDeprecated('icms_ipf_Metagen', sprintf(_CORE_REMOVE_IN_VERSION, '1.4')); }
/** * insert a new object in the database * * @param object $obj reference to the object * @param bool $force whether to force the query execution despite security settings * @param bool $checkObject check if the object is dirty and clean the attributes * @return bool FALSE if failed, TRUE if already present and unchanged or successful */ public function insert(&$obj, $force = false, $checkObject = true, $debug = false) { if ($checkObject != false) { if (!is_object($obj)) { return false; } /** * @TODO: Change to if (!(class_exists($this->className) && $obj instanceof $this->className)) when going fully PHP5 */ if (!is_a($obj, $this->className)) { $obj->setErrors(get_class($obj) . ' Differs from ' . $this->className); return false; } if (!$obj->isDirty()) { $obj->setErrors("Not dirty"); //will usually not be outputted as errors are not displayed when the method returns true, but it can be helpful when troubleshooting code - Mith return true; } } if ($obj->seoEnabled) { // Auto create meta tags if empty $icms_metagen = new icms_ipf_Metagen($obj->title(), $obj->getVar('meta_keywords'), $obj->summary()); if (!$obj->getVar('meta_keywords') || !$obj->getVar('meta_description')) { if (!$obj->meta_keywords()) { $obj->setVar('meta_keywords', $icms_metagen->_keywords); } if (!$obj->meta_description()) { $obj->setVar('meta_description', $icms_metagen->_meta_description); } } // Auto create short_url if empty if (!$obj->short_url()) { $obj->setVar('short_url', $icms_metagen->generateSeoTitle($obj->title('n'), false)); } } $eventResult = $this->executeEvent('beforeSave', $obj); if (!$eventResult) { $obj->setErrors('An error occured during the BeforeSave event'); return false; } if ($obj->isNew()) { $eventResult = $this->executeEvent('beforeInsert', $obj); if (!$eventResult) { $obj->setErrors('An error occured during the BeforeInsert event'); return false; } } else { $eventResult = $this->executeEvent('beforeUpdate', $obj); if (!$eventResult) { $obj->setErrors('An error occured during the BeforeUpdate event'); return false; } } if (!$obj->cleanVars()) { $obj->setErrors('Variables were not cleaned properly.'); return false; } $fieldsToStoreInDB = array(); foreach ($obj->cleanVars as $k => $v) { if ($obj->vars[$k]['data_type'] == XOBJ_DTYPE_INT) { $cleanvars[$k] = (int) $v; } elseif (is_array($v)) { $cleanvars[$k] = $this->db->quoteString(implode(',', $v)); } else { $cleanvars[$k] = $this->db->quoteString($v); } if ($obj->vars[$k]['persistent']) { $fieldsToStoreInDB[$k] = $cleanvars[$k]; } } if ($obj->isNew()) { if (!is_array($this->keyName)) { if ($cleanvars[$this->keyName] < 1) { $cleanvars[$this->keyName] = $this->db->genId($this->table . '_' . $this->keyName . '_seq'); } } $sql = 'INSERT INTO ' . $this->table . ' (' . implode(',', array_keys($fieldsToStoreInDB)) . ') VALUES (' . implode(',', array_values($fieldsToStoreInDB)) . ')'; } else { $sql = 'UPDATE ' . $this->table . ' SET'; foreach ($fieldsToStoreInDB as $key => $value) { if (!is_array($this->keyName) && $key == $this->keyName || is_array($this->keyName) && in_array($key, $this->keyName)) { continue; } if (isset($notfirst)) { $sql .= ','; } $sql .= ' ' . $key . ' = ' . $value; $notfirst = true; } if (is_array($this->keyName)) { $whereclause = ''; for ($i = 0; $i < count($this->keyName); $i++) { if ($i > 0) { $whereclause .= ' AND '; } $whereclause .= $this->keyName[$i] . ' = ' . $obj->getVar($this->keyName[$i]); } } else { $whereclause = $this->keyName . ' = ' . $obj->getVar($this->keyName); } $sql .= ' WHERE ' . $whereclause; } if ($debug) { icms_core_Debug::message($sql); } if (false != $force) { $result = $this->db->queryF($sql); } else { $result = $this->db->query($sql); } if (!$result) { $obj->setErrors($this->db->error()); return false; } if ($obj->isNew() && !is_array($this->keyName)) { $obj->assignVar($this->keyName, $this->db->getInsertId()); } $eventResult = $this->executeEvent('afterSave', $obj); if (!$eventResult) { $obj->setErrors('An error occured during the AfterSave event'); return false; } if ($obj->isNew()) { $obj->unsetNew(); $eventResult = $this->executeEvent('afterInsert', $obj); if (!$eventResult) { $obj->setErrors('An error occured during the AfterInsert event'); return false; } } else { $eventResult = $this->executeEvent('afterUpdate', $obj); if (!$eventResult) { $obj->setErrors('n error occured during the AfterUpdate event'); return false; } } return true; }
$clean_content_id = $contentObj->getVar('content_id'); } $xoopsOption['template_main'] = 'content_content.html'; include_once ICMS_ROOT_PATH . '/header.php'; if (is_object($contentObj) && $contentObj->accessGranted()) { $content_content_handler->updateCounter($clean_content_id); $content = $contentObj->toArray(); $icmsTpl->assign('content_content', $content); $icmsTpl->assign('showInfo', $contentConfig['show_contentinfo']); $showSubs = $contentConfig['show_relateds'] && $content['content_showsubs'] ? true : false; $icmsTpl->assign('showSubs', $showSubs); if ($contentConfig['show_breadcrumb']) { $icmsTpl->assign('content_category_path', $content_content_handler->getBreadcrumbForPid($contentObj->getVar('content_id', 'e'), 1)); } else { $icmsTpl->assign('content_category_path', false); } } else { redirect_header(CONTENT_URL, 3, _NOPERM); } if ($contentConfig['com_rule'] && $contentObj->getVar('content_cancomment')) { $icmsTpl->assign('content_content_comment', true); include_once ICMS_ROOT_PATH . '/include/comment_view.php'; } /** * Generating meta information for this page */ $icms_metagen = new icms_ipf_Metagen($contentObj->getVar('content_title'), $contentObj->getVar('meta_keywords', 'n'), $contentObj->getVar('meta_description', 'n')); $icms_metagen->createMetaTags(); $xoTheme->addStylesheet(ICMS_URL . '/modules/content/include/content.css'); $icmsTpl->assign('content_module_home', content_getModuleName(true, true)); include_once CONTENT_ROOT_PATH . 'footer.php';