当前位置: 首页>>代码示例>>PHP>>正文


PHP ContentHelper::saveContentPrep方法代码示例

本文整理汇总了PHP中ContentHelper::saveContentPrep方法的典型用法代码示例。如果您正苦于以下问题:PHP ContentHelper::saveContentPrep方法的具体用法?PHP ContentHelper::saveContentPrep怎么用?PHP ContentHelper::saveContentPrep使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ContentHelper的用法示例。


在下文中一共展示了ContentHelper::saveContentPrep方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: saveContent

 /**
  * Saves the article an edit form submit
  * @param database A database connector object
  */
 function saveContent()
 {
     global $mainframe;
     // Check for request forgeries
     JRequest::checkToken() or jexit('Invalid Token');
     // Initialize variables
     $db =& JFactory::getDBO();
     $user =& JFactory::getUser();
     $dispatcher =& JDispatcher::getInstance();
     JPluginHelper::importPlugin('content');
     $details = JRequest::getVar('details', array(), 'post', 'array');
     $option = JRequest::getCmd('option');
     $task = JRequest::getCmd('task');
     $sectionid = JRequest::getVar('sectionid', 0, '', 'int');
     $redirect = JRequest::getVar('redirect', $sectionid, 'post', 'int');
     $menu = JRequest::getVar('menu', 'mainmenu', 'post', 'menutype');
     $menuid = JRequest::getVar('menuid', 0, 'post', 'int');
     $nullDate = $db->getNullDate();
     $row =& JTable::getInstance('content');
     if (!$row->bind(JRequest::get('post'))) {
         JError::raiseError(500, $db->stderr());
         return false;
     }
     $row->bind($details);
     // sanitise id field
     $row->id = (int) $row->id;
     $isNew = true;
     // Are we saving from an item edit?
     if ($row->id) {
         $isNew = false;
         $datenow =& JFactory::getDate();
         $row->modified = $datenow->toMySQL();
         $row->modified_by = $user->get('id');
     }
     $row->created_by = $row->created_by ? $row->created_by : $user->get('id');
     if ($row->created && strlen(trim($row->created)) <= 10) {
         $row->created .= ' 00:00:00';
     }
     $config =& JFactory::getConfig();
     $tzoffset = $config->getValue('config.offset');
     $date =& JFactory::getDate($row->created, $tzoffset);
     $row->created = $date->toMySQL();
     // Append time if not added to publish date
     if (strlen(trim($row->publish_up)) <= 10) {
         $row->publish_up .= ' 00:00:00';
     }
     $date =& JFactory::getDate($row->publish_up, $tzoffset);
     $row->publish_up = $date->toMySQL();
     // Handle never unpublish date
     if (trim($row->publish_down) == JText::_('Never') || trim($row->publish_down) == '') {
         $row->publish_down = $nullDate;
     } else {
         if (strlen(trim($row->publish_down)) <= 10) {
             $row->publish_down .= ' 00:00:00';
         }
         $date =& JFactory::getDate($row->publish_down, $tzoffset);
         $row->publish_down = $date->toMySQL();
     }
     // Get a state and parameter variables from the request
     $row->state = JRequest::getVar('state', 0, '', 'int');
     $params = JRequest::getVar('params', null, 'post', 'array');
     // Build parameter INI string
     if (is_array($params)) {
         $txt = array();
         foreach ($params as $k => $v) {
             $txt[] = "{$k}={$v}";
         }
         $row->attribs = implode("\n", $txt);
     }
     // Get metadata string
     $metadata = JRequest::getVar('meta', null, 'post', 'array');
     if (is_array($metadata)) {
         $txt = array();
         foreach ($metadata as $k => $v) {
             if ($k == 'description') {
                 $row->metadesc = $v;
             } elseif ($k == 'keywords') {
                 $row->metakey = $v;
             } else {
                 $txt[] = "{$k}={$v}";
             }
         }
         $row->metadata = implode("\n", $txt);
     }
     // Prepare the content for saving to the database
     ContentHelper::saveContentPrep($row);
     // Make sure the data is valid
     if (!$row->check()) {
         JError::raiseError(500, $db->stderr());
         return false;
     }
     // Increment the content version number
     $row->version++;
     $result = $dispatcher->trigger('onBeforeContentSave', array(&$row, $isNew));
     if (in_array(false, $result, true)) {
         JError::raiseError(500, $row->getError());
//.........这里部分代码省略.........
开发者ID:Isabella570,项目名称:Hotel-Management-Selena-,代码行数:101,代码来源:controller.php

示例2: saveCorresponsalContent

 /**
  * Almacena la noticia enviada por el usuario a traves de una instancia
  * del módulo mod_soycorresponsal.
  */
 function saveCorresponsalContent()
 {
     $mainframe = JFactory::getApplication();
     jimport('json.json');
     $helper = new comZonalesHelper();
     $response = array();
     // chequea irregularidades en el request
     JRequest::checkToken() or jexit('Invalid Token');
     // titulo del modulo que envio el request
     $moduleTitle = JRequest::getVar('module', NULL, 'post', 'string');
     // chequea que el modulo especificado en el request sea valido
     if (!$moduleTitle) {
         jexit($helper->getJsonResponse('failure', 'Error interno', 'No module name'));
     } else {
         jimport('joomla.application.module.helper');
         $module = JModuleHelper::getModule('soycorresponsal', $moduleTitle);
         if ($module->id == 0) {
             jexit($helper->getJsonResponse('failure', 'Error interno', 'Invalid module'));
         }
     }
     // recupera parametros del módulo
     $modparams = new JParameter($module->params);
     // librería recaptcha
     jimport('recaptcha.recaptchalib');
     // parametros del componente
     $zonalesParams =& JComponentHelper::getParams('com_zonales');
     $privatekey = $zonalesParams->get('recaptcha_privatekey', null);
     if (!$privatekey) {
         jexit($helper->getJsonResponse('failure', $modparams->get('error'), 'No recaptcha private key'));
     } else {
         // validamos la respuesta del usuario
         $challenge = JRequest::getVar('recaptcha_challenge_field', NULL, 'post', 'string');
         $response = JRequest::getVar('recaptcha_response_field', NULL, 'post', 'string');
         $resp = recaptcha_check_answer($privatekey, $_SERVER["REMOTE_ADDR"], $challenge, $response);
         if (!$resp->is_valid) {
             jexit($helper->getJsonResponse('captcha-failure', $modparams->get('error'), 'Invalid response'));
         } else {
             // inicializa variables a utilizar
             $db =& JFactory::getDBO();
             $user =& JFactory::getUser();
             if ($user->guest) {
                 $user =& JFactory::getUser($modparams->get('user'));
             }
             //$catid = $modparams->get('category', 0);
             $nullDate = $db->getNullDate();
             // tabla de contenidos joomla
             $row =& JTable::getInstance('content');
             /* if ($catid > 0) {
                $category =& JTable::getInstance('category');
                $category->load($catid);
                $sectionid = $category->section;
                } */
             $nullDate = $db->getNullDate();
             $row->title = JRequest::getVar('title', NULL, 'post', 'string');
             $row->sectionid = 0;
             $row->catid = 0;
             $row->version = 0;
             $row->state = 1;
             $row->ordering = 0;
             $row->images = array();
             $row->publish_down = $nullDate;
             $row->created_by = $user->get('id');
             $row->modified = gmdate('Y-m-d H:i:s');
             // corrección de la fecha
             $config =& JFactory::getConfig();
             $row->created = gmdate('Y-m-d H:i:s');
             $row->publish_up = gmdate('Y-m-d 00:00:00');
             // se redondea timestamp de creación
             if ($row->created && strlen(trim($row->created)) <= 10) {
                 $row->created .= ' 00:00:00';
             }
             // Prepare the content for saving to the database
             require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_content' . DS . 'helper.php';
             ContentHelper::saveContentPrep($row);
             // Se agregan nombre de usuario, correo y telefono
             $enviaNombre = JRequest::getVar('nombre', NULL, 'post', 'string');
             $enviaEmail = JRequest::getVar('email', NULL, 'post', 'string');
             $enviaTel = JRequest::getVar('telefono', NULL, 'post', 'string');
             $row->introtext = $row->introtext . "<p>Envio esta noticia:</p><p>Nombre: {$enviaNombre}<br/>Email: {$enviaEmail}<br/>";
             /**
              * Para videos de YouTube, arreglo la url para que se pueda ver
              */
             $searchString = "watch?v=";
             $imgPos = 0;
             while ($imgPos = strpos($row->introtext, $searchString, $imgPos)) {
                 $strPre = substr($row->introtext, 0, $imgPos);
                 $strPos = substr($row->introtext, $imgPos + strlen($searchString));
                 $row->introtext = $strPre . 'v/' . $strPos;
             }
             // Make sure the data is valid
             if (!$row->check()) {
                 JError::raiseError(500, $db->stderr());
             }
             // Store the content to the database
             if (!$row->store()) {
                 JError::raiseError(500, $db->stderr());
//.........这里部分代码省略.........
开发者ID:BGCX261,项目名称:zonales-svn-to-git,代码行数:101,代码来源:controller.php

示例3: store

 /**
  * Persiste el contenido del modelo en la base de datos.
  *
  * @param boolean $updateNulls FALSE para no actualizar campos que contengan NULL
  * @param boolean $use_post_data TRUE para recuperar datos desde POST
  * @param Array $data Si $use_post_data es FALSE, especifica los datos a persistir
  * @return boolean TRUE si el registro fue guardado exitosamente
  */
 function store($updateNulls = false, $use_post_data = true, $data = null)
 {
     $row =& $this->getTable();
     /**
      * Decide de donde recuperar la información a persistir. Esta puede
      * provenir de las variables POST, ser los datos ya contenidos en el
      * modelo ($this->_data) o ser especificada por medio del parametro
      * $data.
      */
     if ($use_post_data) {
         $data = JRequest::get('post');
     } else {
         if (is_null($data)) {
             $data = $this->_data;
         } else {
             $this->_data = $data;
         }
     }
     /**
      * Realiza el binding de los datos a persistir con el objeto JTable, y
      * ejecuta a continuación el método afterBind(). Este último metodo
      * debe ser sobrecargado en los modelos que extiendan BaseModel.
      */
     if (!$row->bind($data)) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     $this->afterBind($row);
     // Texto generado por editor
     if (!is_null(JRequest::getVar('text', null))) {
         ContentHelper::saveContentPrep($row);
     }
     // Almancena los metadatos si estos estan presentes
     $metadata = JRequest::getVar('meta', null, 'post', 'array');
     if (is_array($metadata)) {
         $txt = array();
         foreach ($metadata as $k => $v) {
             if ($k == 'description') {
                 $row->metadesc = $v;
             } elseif ($k == 'keywords') {
                 $row->metakey = $v;
             } else {
                 $txt[] = "{$k}={$v}";
             }
         }
         $row->metadata = implode("\n", $txt);
     }
     /**
      * Realiza el chequeo de los datos a persistir. En caso de éxito pasa
      * a ejecutar el metodo afterCheck() el cual debe ser sobrecargado en
      * los modelos que extiendan BaseModel para ofrecer chequeos especificos
      * para cada caso.
      */
     if (!$row->check()) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     $this->afterCheck($row);
     // Persiste el modelo en la base de datos
     if (JError::isError($row->store($updateNulls))) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     // ¿Hack?
     $this->setId($row->id);
     return true;
 }
开发者ID:BGCX261,项目名称:zonales-svn-to-git,代码行数:75,代码来源:basemodel.php

示例4: saveArticle

 function saveArticle()
 {
     // Initialize variables
     $db =& FabrikWorker::getDbo();
     $user =& JFactory::getUser();
     $dispatcher =& JDispatcher::getInstance();
     JPluginHelper::importPlugin('content');
     $this->_postFabrikDataAsArticleData();
     $details = JRequest::getVar('details', array(), 'post', 'array');
     $option = JRequest::getCmd('option');
     $sectionid = JRequest::getVar('sectionid', 0, '', 'int');
     $nullDate = $db->getNullDate();
     $row =& FabTable::getInstance('content');
     if (!$row->bind(JRequest::get('post'))) {
         JError::raiseError(500, $db->stderr());
         return false;
     }
     $row->bind($details);
     // sanitise id field
     $row->id = (int) $row->id;
     $this->_isNew = true;
     // Are we saving from an item edit?
     if ($row->id) {
         $this->_isNew = false;
         $datenow = JFactory::getDate();
         $row->modified = $datenow->toMySQL();
         $row->modified_by = $user->get('id');
     }
     $row->created_by = $row->created_by ? $row->created_by : $user->get('id');
     if ($row->created && strlen(trim($row->created)) <= 10) {
         $row->created .= ' 00:00:00';
     }
     $config =& JFactory::getConfig();
     $tzoffset = $config->getValue('config.offset');
     $date =& JFactory::getDate($row->created, $tzoffset);
     $row->created = $date->toMySQL();
     // Append time if not added to publish date
     if (strlen(trim($row->publish_up)) <= 10) {
         $row->publish_up .= ' 00:00:00';
     }
     $date =& JFactory::getDate($row->publish_up, $tzoffset);
     $row->publish_up = $date->toMySQL();
     // Handle never unpublish date
     if (trim($row->publish_down) == JText::_('Never') || trim($row->publish_down) == '') {
         $row->publish_down = $nullDate;
     } else {
         if (strlen(trim($row->publish_down)) <= 10) {
             $row->publish_down .= ' 00:00:00';
         }
         $date =& JFactory::getDate($row->publish_down, $tzoffset);
         $row->publish_down = $date->toMySQL();
     }
     // Get a state and parameter variables from the request
     // should probably punt this logic into the controller, but for now ...
     $articlePublishElementName = $this->_elementBaseName($this->_articlePublishElement);
     $row->state = $this->_formModel->_formData[$articlePublishElementName];
     // probably an array, i.e. coming from a yes/no radio or dropdown
     if (is_array($row->state)) {
         $row->state = $row->state[0];
     }
     $params = JRequest::getVar('params', null, 'post', 'array');
     $row->params = json_encode($params);
     // Get metadata string
     $metadata = JRequest::getVar('meta', null, 'post', 'array');
     if (is_array($metadata)) {
         $txt = array();
         foreach ($metadata as $k => $v) {
             if ($k == 'description') {
                 $row->metadesc = $v;
             } elseif ($k == 'keywords') {
                 $row->metakey = $v;
             } else {
                 $txt[] = "{$k}={$v}";
             }
         }
         $row->metadata = implode("\n", $txt);
     }
     // Prepare the content for saving to the database
     ContentHelper::saveContentPrep($row);
     // Make sure the data is valid
     if (!$row->check()) {
         JError::raiseError(500, $db->stderr());
         return false;
     }
     // Increment the content version number
     $row->version++;
     $result = $dispatcher->trigger('onBeforeContentSave', array(&$row, $this->_isNew));
     if (in_array(false, $result, true)) {
         JError::raiseError(500, $row->getError());
         return false;
     }
     // Store the content to the database
     if (!$row->store()) {
         JError::raiseError(500, $db->stderr());
         return false;
     }
     $this->_articleId = $row->id;
     // Check the article and update item order
     $row->checkin();
     $row->reorder('catid = ' . (int) $row->catid . ' AND state >= 0');
//.........这里部分代码省略.........
开发者ID:juliano-hallac,项目名称:fabrik,代码行数:101,代码来源:article.php

示例5: store

 /**
  * Salva el contenido del modelo en la base de datos.
  *
  * @param boolean $updateNulls
  * @param boolean $use_post_data
  * @param Array $data datos a almacenar (no tomar del post)
  * @return boolean true si el registro fue guardado exitosamente
  */
 function store($updateNulls = false, $use_post_data = true, $data = null)
 {
     $row =& $this->getTable();
     //$data = $use_post_data ? JRequest::get('post') : $this->_data;
     if ($use_post_data) {
         $data = JRequest::get('post');
     } else {
         if (is_null($data)) {
             $data = $this->_data;
         } else {
             $this->_data = $data;
         }
     }
     if (!$row->bind($data)) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     $this->afterBind($row);
     // Texto generado por editor
     if (!is_null(JRequest::getVar('text', null))) {
         ContentHelper::saveContentPrep($row);
     }
     // Almancena los metadatos si estos estan presentes
     $metadata = JRequest::getVar('meta', null, 'post', 'array');
     if (is_array($metadata)) {
         $txt = array();
         foreach ($metadata as $k => $v) {
             if ($k == 'description') {
                 $row->metadesc = $v;
             } elseif ($k == 'keywords') {
                 $row->metakey = $v;
             } else {
                 $txt[] = "{$k}={$v}";
             }
         }
         $row->metadata = implode("\n", $txt);
     }
     // Make sure the record is valid
     if (!$row->check()) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     $this->afterCheck($row);
     // Store the table to the database
     //if (!$row->store($updateNulls)) {
     if (JError::isError($row->store($updateNulls))) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     // ¿Hack?
     $this->setId($row->id);
     return true;
 }
开发者ID:BGCX261,项目名称:zonales-svn-to-git,代码行数:61,代码来源:basemodel.php


注:本文中的ContentHelper::saveContentPrep方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。