本文整理汇总了PHP中DBG类的典型用法代码示例。如果您正苦于以下问题:PHP DBG类的具体用法?PHP DBG怎么用?PHP DBG使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DBG类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: startQuery
/**
* {@inheritdoc}
*/
public function startQuery($sql, array $params = null, array $types = null)
{
$this->query = null;
if (!(\DBG::getMode() & DBG_DOCTRINE) && !(\DBG::getMode() & DBG_DOCTRINE_CHANGE) && !(\DBG::getMode() & DBG_DOCTRINE_ERROR)) {
return;
}
// prepare SQL statement
if ($params) {
$sql = str_replace('?', "'%s'", $sql);
//$this->query = vsprintf($sql, $params);
foreach ($params as &$param) {
// serialize arrays
if (is_array($param)) {
$param = serialize($param);
} elseif (is_object($param)) {
// serialize objects
switch (get_class($param)) {
case 'DateTime':
// output DateTime object as date literal
$param = $param->format(ASCMS_DATE_FORMAT_DATETIME);
break;
default:
break;
}
}
}
$sql = vsprintf($sql, $params);
}
\DBG::logSQL($sql);
$this->startTime = microtime(true);
}
示例2: _marketUpdate
/**
* Cloudrexx
*
* @link http://www.cloudrexx.com
* @copyright Cloudrexx AG 2007-2015
*
* According to our dual licensing model, this program can be used either
* under the terms of the GNU Affero General Public License, version 3,
* or under a proprietary license.
*
* The texts of the GNU Affero General Public License with an additional
* permission and of our proprietary license can be found at and
* in the LICENSE file you have received along with this program.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* "Cloudrexx" is a registered trademark of Cloudrexx AG.
* The licensing of the program under the AGPLv3 does not imply a
* trademark license. Therefore any rights, title and interest in
* our trademarks remain entirely with us.
*/
function _marketUpdate()
{
global $objDatabase, $_ARRAYLANG;
$query = "SELECT id FROM " . DBPREFIX . "module_market_settings WHERE name='codeMode'";
$objCheck = $objDatabase->SelectLimit($query, 1);
if ($objCheck !== false) {
if ($objCheck->RecordCount() == 0) {
$query = "INSERT INTO `" . DBPREFIX . "module_market_settings` ( `id` , `name` , `value` , `description` , `type` )\n VALUES ( NULL , 'codeMode', '1', 'TXT_MARKET_SET_CODE_MODE', '2')";
if ($objDatabase->Execute($query) === false) {
return _databaseError($query, $objDatabase->ErrorMsg());
}
}
} else {
return _databaseError($query, $objDatabase->ErrorMsg());
}
$arrColumns = $objDatabase->MetaColumns(DBPREFIX . 'module_market_mail');
if ($arrColumns === false) {
setUpdateMsg(sprintf($_ARRAYLANG['TXT_UNABLE_GETTING_DATABASE_TABLE_STRUCTURE'], DBPREFIX . 'module_market_mail'));
return false;
}
if (!isset($arrColumns['MAILTO'])) {
$query = "ALTER TABLE `" . DBPREFIX . "module_market_mail` ADD `mailto` VARCHAR( 10 ) NOT NULL AFTER `content`";
if ($objDatabase->Execute($query) === false) {
return _databaseError($query, $objDatabase->ErrorMsg());
}
}
/*****************************************************************
* EXTENSION: New attributes 'color' and 'sort_id' for entries *
* ADDED: Contrexx v2.1.0 *
*****************************************************************/
$arrColumns = $objDatabase->MetaColumns(DBPREFIX . 'module_market');
if ($arrColumns === false) {
setUpdateMsg(sprintf($_ARRAYLANG['TXT_UNABLE_GETTING_DATABASE_TABLE_STRUCTURE'], DBPREFIX . 'module_market'));
return false;
}
if (!isset($arrColumns['SORT_ID'])) {
$query = "ALTER TABLE `" . DBPREFIX . "module_market` ADD `sort_id` INT( 4 ) NOT NULL DEFAULT '0' AFTER `paypal`";
if ($objDatabase->Execute($query) === false) {
return _databaseError($query, $objDatabase->ErrorMsg());
}
}
if (!isset($arrColumns['COLOR'])) {
$query = "ALTER TABLE `" . DBPREFIX . "module_market` ADD `color` VARCHAR(50) NOT NULL DEFAULT '' AFTER `description`";
if ($objDatabase->Execute($query) === false) {
return _databaseError($query, $objDatabase->ErrorMsg());
}
}
try {
// delete obsolete table contrexx_module_market_access
\Cx\Lib\UpdateUtil::drop_table(DBPREFIX . 'module_market_access');
\Cx\Lib\UpdateUtil::table(DBPREFIX . 'module_market_spez_fields', array('id' => array('type' => 'INT(5)', 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'name' => array('type' => 'VARCHAR(100)'), 'value' => array('type' => 'VARCHAR(100)'), 'type' => array('type' => 'INT(1)', 'notnull' => true, 'default' => '1'), 'lang_id' => array('type' => 'INT(2)', 'notnull' => true, 'default' => '0'), 'active' => array('type' => 'INT(1)', 'notnull' => true, 'default' => '0')));
} catch (\Cx\Lib\UpdateException $e) {
DBG::trace();
return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
}
return true;
}
示例3: onEvent
/**
* Event handler to add logs
*
* We need to do this with an event handler so there's no dependency to this component
* @param string $eventName Name of triggered event, should always be static::EVENT_NAME
* @param array $eventArgs Supplied arguments, should be an array (see DBG message below)
*/
public function onEvent($eventName, array $eventArgs)
{
if ($eventName != static::EVENT_NAME) {
return;
}
if (empty($eventArgs['severity']) || empty($eventArgs['message']) || empty($eventArgs['data'])) {
\DBG::msg('Triggered event "SysLog/Add" with wrong arguments. I need an array with non-empty values for the keys "severity", "message" and "data"');
return;
}
$this->addSysLog(new \Cx\Core_Modules\SysLog\Model\Entity\Log($eventArgs['severity'], $eventArgs['message'], $eventArgs['data']));
}
示例4: _auctionUpdate
/**
* Cloudrexx
*
* @link http://www.cloudrexx.com
* @copyright Cloudrexx AG 2007-2015
*
* According to our dual licensing model, this program can be used either
* under the terms of the GNU Affero General Public License, version 3,
* or under a proprietary license.
*
* The texts of the GNU Affero General Public License with an additional
* permission and of our proprietary license can be found at and
* in the LICENSE file you have received along with this program.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* "Cloudrexx" is a registered trademark of Cloudrexx AG.
* The licensing of the program under the AGPLv3 does not imply a
* trademark license. Therefore any rights, title and interest in
* our trademarks remain entirely with us.
*/
function _auctionUpdate()
{
try {
// delete obsolete table contrexx_module_auction_access
\Cx\Lib\UpdateUtil::drop_table(DBPREFIX . 'module_auction_access');
} catch (\Cx\Lib\UpdateException $e) {
// we COULD do something else here..
DBG::trace();
return \Cx\Lib\UpdateUtil::DefaultActionHandler($e);
}
return true;
}
示例5: convertIdnToUtf8Format
/**
* Convert idn to utf8 format
*
* @param string $name
*
* @return string
*/
public static function convertIdnToUtf8Format($name)
{
if (empty($name)) {
return;
}
if (!function_exists('idn_to_utf8')) {
\DBG::msg('Idn is not supported in this system.');
} else {
$name = idn_to_utf8($name);
}
return $name;
}
示例6: clearCachePageForDomainAndPort
/**
* Clears a cache page
* @param string $urlPattern Drop all pages that match the pattern, for exact format, make educated guesses
* @param string $domain Domain name to drop cache page of
* @param int $port Port to drop cache page of
*/
protected function clearCachePageForDomainAndPort($urlPattern, $domain, $port)
{
$errno = 0;
$errstr = '';
$varnishSocket = fsockopen($this->hostname, $this->port, $errno, $errstr);
if (!$varnishSocket) {
\DBG::log('Varnish error: ' . $errstr . ' (' . $errno . ') on server ' . $this->hostname . ':' . $this->port);
}
$domainOffset = ASCMS_PATH_OFFSET;
$request = 'BAN ' . $domainOffset . $urlPattern . " HTTP/1.0\r\n";
$request .= 'Host: ' . $domain . ':' . $port . "\r\n";
$request .= "User-Agent: Cloudrexx Varnish Cache Clear\r\n";
$request .= "Connection: Close\r\n\r\n";
fwrite($varnishSocket, $request);
fclose($varnishSocket);
}
示例7: execute
protected function execute()
{
switch ($this->mode) {
case self::MODE_DQL:
$this->result = '';
$strQuery = trim($this->code);
$lister = new \Cx\Core_Modules\Listing\Controller\ListingController(function (&$offset, &$count, &$criteria, &$order) use($strQuery) {
return \Env::get('em')->createQuery($strQuery);
});
try {
$table = new \BackendTable($lister->getData());
$this->result = $table->toHtml() . $lister;
} catch (\Exception $e) {
$this->result = 'Could not execute query (' . $e->getMessage() . ')!';
}
break;
case self::MODE_PHP:
$dbgMode = \DBG::getMode();
try {
// This error handler catches all Warnings and Notices and some Strict errors
\DBG::activate(DBG_PHP);
set_error_handler(array($this, 'phpErrorsAsExceptionsHandler'));
$this->errrorHandlerActive = true;
// Since DBG catches the rest (E_PARSE) let's use that
ob_start();
$function = create_function('$em, $cx', '' . $this->code . ';');
$dbgContents = ob_get_clean();
\DBG::activate($dbgMode);
if (!is_callable($function)) {
// parse exception
throw new SandboxException($dbgContents);
}
$this->result = var_export($function(\Env::get('em'), \Env::get('cx')), true);
restore_error_handler();
$this->errrorHandlerActive = false;
} catch (\Exception $e) {
\DBG::activate($dbgMode);
restore_error_handler();
$this->errrorHandlerActive = false;
$this->result = get_class($e) . ': ' . $e->getMessage();
}
break;
default:
break;
}
}
示例8: set
public static function set($prop, &$val)
{
switch ($prop) {
case 'cx':
// set is only used for installerCx. Normal cx class will load with \Env::get('cx')
self::$props[$prop] = $val;
\DBG::msg(__METHOD__ . ": Setting '{$prop}' is deprecated. Use only for installer, otherwise use \\Env::('{$prop}')");
\DBG::stack();
break;
case 'em':
self::$props[$prop] = $val;
\DBG::msg(__METHOD__ . ": Setting '{$prop}' is deprecated. Env::get({$prop}) always returns the active/preferred instance of {$prop}.");
\DBG::stack();
break;
default:
self::$props[$prop] = $val;
break;
}
}
示例9: processRequest
public static function processRequest($token, $arrOrder)
{
global $_CONFIG;
if (empty($token)) {
return array('status' => 'error', 'message' => 'invalid token');
}
$testMode = intval(\Cx\Core\Setting\Controller\Setting::getValue('paymill_use_test_account', 'Shop')) == 0;
$apiKey = $testMode ? \Cx\Core\Setting\Controller\Setting::getValue('paymill_test_private_key', 'Shop') : \Cx\Core\Setting\Controller\Setting::getValue('paymill_live_private_key', 'Shop');
if ($token) {
try {
$request = new Paymill\Request($apiKey);
$transaction = new Paymill\Models\Request\Transaction();
$transaction->setAmount($arrOrder['amount'])->setCurrency($arrOrder['currency'])->setToken($token)->setDescription($arrOrder['note'])->setSource('contrexx_' . $_CONFIG['coreCmsVersion']);
DBG::log("Transactoin created with token:" . $token);
$response = $request->create($transaction);
$paymentId = $response->getId();
DBG::log("Payment ID" . $paymentId);
return array('status' => 'success', 'payment_id' => $paymentId);
} catch (\Paymill\Services\PaymillException $e) {
//Do something with the error informations below
return array('status' => 'error', 'response_code' => $e->getResponseCode(), 'status_code' => $e->getStatusCode(), 'message' => $e->getErrorMessage());
}
}
}
示例10: editMedia
/**
* Shows the image manipulation component.
*
* @global array $_ARRAYLANG
* @return string Parsed content.
*/
function editMedia()
{
global $_ARRAYLANG;
$this->_objTpl->loadTemplateFile('module_media_edit.html', true, true);
$this->pageTitle = $_ARRAYLANG['TXT_MEDIA_EDIT_FILE'];
if (isset($_GET['saveError']) && $_GET['saveError'] === 'true') {
$this->_objTpl->setVariable(array('TXT_MEDIA_ERROR_OCCURED' => $_ARRAYLANG['TXT_MEDIA_ERROR_OCCURED'], 'TXT_MEDIA_ERROR_MESSAGE' => $_ARRAYLANG['TXT_MEDIA_CANNOT_SAVE_IMAGE']));
$this->_objTpl->parse('mediaErrorFile');
return;
}
// Activate cx
\JS::activate('cx');
// Activate jQuery and imgAreaSelect
\JS::activate('jquery');
\JS::activate('jquery-imgareaselect');
try {
// Get quality options from the settings
$arrImageSettings = $this->getImageSettings();
} catch (\Exception $e) {
\DBG::msg('Could not query image settings: ' . $e->getMessage());
}
$check = true;
empty($this->getFile) ? $check = false : '';
empty($this->getPath) ? $check = false : '';
!file_exists($this->path . $this->getFile) ? $check = false : '';
if ($check) {
// File exists
$this->_objTpl->setVariable(array('TXT_MEDIA_SAVE' => $_ARRAYLANG['TXT_MEDIA_SAVE'], 'TXT_MEDIA_SAVE_AS' => $_ARRAYLANG['TXT_MEDIA_SAVE_AS'], 'TXT_MEDIA_RESET' => $_ARRAYLANG['TXT_MEDIA_RESET'], 'TXT_MEDIA_PREVIEW' => $_ARRAYLANG['TXT_PREVIEW'], 'MEDIA_EDIT_ACTION' => 'index.php?cmd=Media&archive=' . $this->archive . '&act=editImage&path=' . $this->webPath, 'MEDIA_DIR' => $this->webPath, 'MEDIA_FILE' => $this->getFile));
$icon = $this->_getIcon($this->path . $this->getFile);
$info = pathinfo($this->getFile);
$fileExt = $info['extension'];
$ext = !empty($fileExt) ? '.' . $fileExt : '';
$fileName = substr($this->getFile, 0, strlen($this->getFile) - strlen($ext));
// Icon, file & extension name
$this->_objTpl->setVariable(array('MEDIA_FILE_ICON' => self::_getIconWebPath() . $icon . '.png', 'MEDIA_FILE_DIR' => $this->webPath, 'MEDIA_FILE_NAME' => $fileName, 'MEDIA_FILE_EXT' => $fileExt));
// Edit image
$imageSize = @getimagesize($this->path . $this->getFile);
$this->_objTpl->setVariable(array('TXT_MEDIA_IMAGE_MANIPULATION' => $_ARRAYLANG['TXT_MEDIA_IMAGE_MANIPULATION'], 'TXT_MEDIA_WIDTH' => $_ARRAYLANG['TXT_MEDIA_WIDTH'], 'TXT_MEDIA_HEIGHT' => $_ARRAYLANG['TXT_MEDIA_HEIGHT'], 'TXT_MEDIA_BALANCE' => $_ARRAYLANG['TXT_MEDIA_BALANCE'], 'TXT_MEDIA_QUALITY' => $_ARRAYLANG['TXT_MEDIA_QUALITY'], 'TXT_MEDIA_SAVE' => $_ARRAYLANG['TXT_MEDIA_SAVE'], 'TXT_MEDIA_RESET' => $_ARRAYLANG['TXT_MEDIA_RESET'], 'TXT_MEDIA_SET_IMAGE_NAME' => $_ARRAYLANG['TXT_MEDIA_SET_IMAGE_NAME'], 'TXT_MEDIA_CONFIRM_REPLACE_IMAGE' => $_ARRAYLANG['TXT_MEDIA_CONFIRM_REPLACE_IMAGE'], 'TXT_MEDIA_REPLACE' => $_ARRAYLANG['TXT_MEDIA_REPLACE'], 'TXT_MEDIA_OR' => $_ARRAYLANG['TXT_MEDIA_OR'], 'TXT_MEDIA_SAVE_NEW_COPY' => $_ARRAYLANG['TXT_MEDIA_SAVE_NEW_COPY'], 'TXT_MEDIA_CROP' => $_ARRAYLANG['TXT_MEDIA_CROP'], 'TXT_MEDIA_CROP_INFO' => $_ARRAYLANG['TXT_MEDIA_CROP_INFO'], 'TXT_MEDIA_CANCEL' => $_ARRAYLANG['TXT_MEDIA_CANCEL'], 'TXT_MEDIA_ROTATE' => $_ARRAYLANG['TXT_MEDIA_ROTATE'], 'TXT_MEDIA_ROTATE_INFO' => $_ARRAYLANG['TXT_MEDIA_ROTATE_INFO'], 'TXT_MEDIA_SCALE_COMPRESS' => $_ARRAYLANG['TXT_MEDIA_SCALE_COMPRESS'], 'TXT_MEDIA_SCALE_INFO' => $_ARRAYLANG['TXT_MEDIA_SCALE_INFO'], 'TXT_MEDIA_PREVIEW' => $_ARRAYLANG['TXT_MEDIA_PREVIEW'], 'MEDIA_IMG_WIDTH' => $imageSize[0], 'MEDIA_IMG_HEIGHT' => $imageSize[1]));
foreach ($this->arrImageQualityValues as $value) {
$this->_objTpl->setVariable(array('IMAGE_QUALITY_VALUE' => $value, 'IMAGE_QUALITY_OPTION_CHECKED' => $value == $arrImageSettings['image_compression'] ? 'selected="selected"' : ''));
$this->_objTpl->parse('mediaEditImageQualityOptions');
}
$this->_objTpl->parse('mediaEditImage');
} else {
// File doesn't exist
$this->_objTpl->setVariable(array('TXT_MEDIA_ERROR_OCCURED' => $_ARRAYLANG['TXT_MEDIA_ERROR_OCCURED'], 'TXT_MEDIA_ERROR_MESSAGE' => $_ARRAYLANG['TXT_MEDIA_FILE_DONT_EXISTS']));
$this->_objTpl->parse('mediaErrorFile');
}
// Variables
$this->_objTpl->setVariable(array('CSRF' => \Cx\Core\Csrf\Controller\Csrf::param(), 'MEDIA_EDIT_AJAX_ACTION' => 'index.php?cmd=Media&archive=' . $this->archive . '&act=editImage&path=' . $this->webPath, 'MEDIA_EDIT_REDIRECT' => 'index.php?cmd=Media&archive=' . $this->archive . '&path=' . $this->webPath, 'MEDIA_BACK_HREF' => 'index.php?cmd=Media&archive=' . $this->archive . '&path=' . $this->webPath, 'MEDIA_FILE_IMAGE_SRC' => 'index.php?cmd=Media&archive=' . $this->archive . '&act=getImage&path=' . $this->webPath . '&file=' . $this->getFile . '&' . \Cx\Core\Csrf\Controller\Csrf::param(), 'MEDIA_IMAGE_WIDTH' => !empty($imageSize) ? intval($imageSize[0]) : 0, 'MEDIA_IMAGE_HEIGHT' => !empty($imageSize) ? intval($imageSize[1]) : 0, 'MEDIA_IMAGE_CROP_WIDTH' => $arrImageSettings['image_cut_width'], 'MEDIA_IMAGE_CROP_HEIGHT' => $arrImageSettings['image_cut_height'], 'MEDIA_IMAGE_RESIZE_QUALITY' => $arrImageSettings['image_compression']));
}
示例11: convertAllThemesToComponent
/**
* Generate a component.yml for each theme available on the system
* only used in update process for fixing invalid themes
*/
public function convertAllThemesToComponent()
{
foreach ($this->findAll() as $theme) {
if ($theme->isComponent()) {
continue;
}
try {
$this->convertThemeToComponent($theme);
} catch (\Exception $ex) {
\DBG::log($ex->getMessage());
\DBG::log($theme->getThemesname() . ' : Unable to convert theme to component');
}
}
}
示例12: saveEntry
//.........这里部分代码省略.........
$associatedEntityClassMetadata = $em->getClassMetadata($value["targetEntity"]);
foreach ($_POST[$relatedClassInputFieldName] as $relatedPostData) {
$entityData = array();
parse_str($relatedPostData, $entityData);
// if we have already an entry (on update) we take the existing one and update it.
// Otherwise we create a new one
if (isset($entityData['id']) && $entityData['id'] != 0) {
// update/edit case
$associatedClassRepo = $em->getRepository($value["targetEntity"]);
$associatedEntity = $associatedClassRepo->find($entityData['id']);
} else {
// add case
$associatedEntity = $associatedEntityClassMetadata->newInstance();
}
// if there are any entries which the user wants to delete, we delete them here
if (isset($entityData['delete']) && $entityData['delete'] == 1) {
$em->remove($associatedEntity);
}
// save the "n" associated class data to its class
$this->savePropertiesToClass($associatedEntity, $associatedEntityClassMetadata, $entityData, $entityWithNS);
// Linking 1: link the associated entity to the main entity for doctrine
$methodName = 'add' . str_replace(' ', '', ucwords(str_replace('_', ' ', $name)));
if (!in_array($methodName, $classMethods)) {
\Message::add(sprintf($_ARRAYLANG['TXT_CORE_RECORD_FUNCTION_NOT_FOUND'], $name, $methodName), \Message::CLASS_ERROR);
continue;
}
$entity->{$methodName}($associatedEntity);
// Linking 2: link the main entity to its associated entity. This should normally be done by
// 'Linking 1' but because not all components have implemented this, we do it here by ourselves
$method = 'set' . ucfirst($value["mappedBy"]);
if (method_exists($associatedEntity, $method)) {
$associatedEntity->{$method}($entity);
}
// buffer entity, so we can persist it later
$associatedEntityToPersist[] = $associatedEntity;
}
}
}
if ($entityId != 0) {
// edit case
// update the main entry in doctrine so we can store it over doctrine to database later
$this->savePropertiesToClass($entity, $entityClassMetadata);
$param = 'editid';
$successMessage = $_ARRAYLANG['TXT_CORE_RECORD_UPDATED_SUCCESSFUL'];
} else {
// add case
// save main formular class data to its class over $_POST
$this->savePropertiesToClass($entity, $entityClassMetadata);
$param = 'add';
$successMessage = $_ARRAYLANG['TXT_CORE_RECORD_ADDED_SUCCESSFUL'];
}
$showSuccessMessage = false;
if ($entity instanceof \Cx\Core\Model\Model\Entity\YamlEntity) {
// Save the yaml entities
$entityRepository = $em->getRepository($entityWithNS);
if (!$entityRepository->isManaged($entity)) {
$entityRepository->add($entity);
}
$entityRepository->flush();
$showSuccessMessage = true;
} else {
if ($entity instanceof \Cx\Model\Base\EntityBase) {
/* We try to store the prepared em. This may fail if (for example) we have a one to many association which
can not be null but was not set in the post request. This cases should be caught here. */
try {
// persist main entity. This must be done first, otherwise saving oneToManyAssociated entities won't work
$em->persist($entity);
// now we can persist the associated entities. We need to do this, because otherwise it will fail,
// if yaml does not contain a cascade option
foreach ($associatedEntityToPersist as $associatedEntity) {
$em->persist($associatedEntity);
}
$em->flush();
$showSuccessMessage = true;
} catch (\Cx\Core\Error\Model\Entity\ShinyException $e) {
/* Display the message from the exception. If this message is empty, we output a general message,
so the user knows what to do in every case */
if ($e->getMessage() != "") {
\Message::add($e->getMessage(), \Message::CLASS_ERROR);
} else {
\Message::add($_ARRAYLANG['TXT_CORE_RECORD_UNKNOWN_ERROR'], \Message::CLASS_ERROR);
}
return;
} catch (\Exception $e) {
echo $e->getMessage();
die;
}
} else {
\Message::add($_ARRAYLANG['TXT_CORE_RECORD_VALIDATION_FAILED'], \Message::CLASS_ERROR);
\DBG::msg('Unkown entity model ' . get_class($entity) . '! Trying to persist using entity manager...');
}
}
if ($showSuccessMessage) {
\Message::add($successMessage);
}
// get the proper action url and redirect the user
$actionUrl = clone $cx->getRequest()->getUrl();
$actionUrl->setParam($param, null);
\Cx\Core\Csrf\Controller\Csrf::redirect($actionUrl);
}
示例13: getSqlSnippets
/**
* Returns an array of SQL snippets to include the selected Text records
* in the query.
*
* Provide a single value for the $key, or an array.
* If you use an array, the array keys *MUST* contain distinct alias names
* for the respective text keys.
* The array returned looks as follows:
* array(
* 'alias' => The array of Text field aliases:
* array(key => field name alias, ...)
* Use the alias to access the text content in the resulting
* recordset, or if you need to sort the result by that
* column.
* 'field' => Field snippet to be included in the SQL SELECT, uses
* aliased field names for the id ("text_#_id") and text
* ("text_#_text") fields.
* No leading comma is included!
* 'join' => SQL JOIN snippet, the LEFT JOIN with the core_text table
* and conditions
* )
* The '#' is replaced by a unique integer number.
* The '*' may be any descriptive part of the name that disambiguates
* multiple foreign keys in a single table, like 'name', or 'value'.
* Note that the $lang_id parameter is mandatory and *MUST NOT* be
* emtpy. $alias may be null (or omitted), in which case it is ignored,
* and the default form "text_<index>" is used, where <index> is an integer
* incremented on each use.
* @static
* @param string $field_id The name of the text ID
* foreign key field. Note that this
* is not part of the SELECTed fields,
* but used in the JOIN only.
* @param integer $lang_id The language ID
* @param string $section The section
* @param mixed $keys A single key, or an array thereof
* @return array The array with SQL code parts
* @author Reto Kohli <reto.kohli@comvation.com>
*/
static function getSqlSnippets($field_id, $lang_id, $section, $keys)
{
static $table_alias_index = 0;
if (empty($field_id)) {
DBG::log("Text::getSqlSnippets(): ERROR: Empty field ID");
return false;
}
if (empty($lang_id)) {
DBG::log("Text::getSqlSnippets(): ERROR: Empty language ID");
return false;
}
if (empty($section)) {
DBG::log("Text::getSqlSnippets(): ERROR: Empty section");
return false;
}
if (empty($keys)) {
DBG::log("Text::getSqlSnippets(): ERROR: Empty keys");
return false;
}
if (!is_array($keys)) {
$keys = array($keys);
}
$query_field = '';
$query_join = '';
$arrSql = array();
foreach ($keys as $alias => $key) {
$table_alias = 'text_' . ++$table_alias_index;
$field_id_alias = $table_alias . '_id';
$field_text_alias = $alias ? $alias : $table_alias . '_text';
$field_text_name = "`{$table_alias}`.`text`";
$query_field .= ($query_field ? ', ' : '') . "\n `{$table_alias}`.`id` AS `{$field_id_alias}`,\n {$field_text_name} AS `{$field_text_alias}`";
$query_join .= "\n LEFT JOIN `" . DBPREFIX . "core_text` as `{$table_alias}`\n ON `{$table_alias}`.`id`={$field_id}\n AND `{$table_alias}`.`lang_id`={$lang_id}\n AND `{$table_alias}`.`section`" . (isset($section) ? "='" . addslashes($section) . "'" : ' IS NULL') . "\n AND `{$table_alias}`.`key`='" . addslashes($key) . "'";
$arrSql['alias'][$alias] = $field_text_name;
}
$arrSql['field'] = $query_field;
$arrSql['join'] = $query_join;
//DBG::log("Text::getSqlSnippets(): field: {$arrSql['field']}");
//DBG::log("Text::getSqlSnippets(): join: {$arrSql['join']}");
return $arrSql;
}
示例14: urlfind
/**
* Find the url exists or not
*
* @param string $url url
*
* @return boolean true on url exists, false otherwise
*/
function urlfind($url)
{
if (!ini_get('allow_url_fopen')) {
ini_set('allow_url_fopen', 'On');
}
if (ini_get('allow_url_fopen')) {
if ($url) {
$file = @fopen($url . '/modules/Calendar/Controller/CalendarWebserviceServer.class.php', "r");
}
if ($file) {
fclose($file);
return true;
} else {
return false;
}
} else {
try {
$request = new \HTTP_Request2($url . 'modules/Calendar/Controller/CalendarWebserviceServer.class.php');
$response = $request->send();
if (404 == $response->getStatus()) {
return false;
} else {
return true;
}
} catch (Exception $e) {
\DBG::msg($e->getMessage());
return false;
}
}
}
示例15: getJson
/**
* Fetches a json response via HTTP request
* @todo Support cookies (to allow login and similiar features)
* @param string $url URL to get json from
* @param array $data (optional) HTTP post data
* @param boolean $secure (optional) Wheter to verify peer using SSL or not, default false
* @param string $certificateFile (optional) Local certificate file for non public SSL certificates
* @param array Set an optional HTTP Authentication method and supply its login credentials.
* The supplied array must comply with the following structure:
* <pre class="brush: php">
* $httpAuth = array(
* 'httpAuthMethod' => 'none|basic|disgest',
* 'httpAuthUsername' => '<username>',
* 'httpAuthPassword' => '<password>',
* );
* </pre>
* @return mixed Decoded JSON on success, false otherwise
*/
public function getJson($url, $data = array(), $secure = false, $certificateFile = '', $httpAuth = array(), $files = array())
{
$request = new \HTTP_Request2($url, \HTTP_Request2::METHOD_POST);
if (!empty($httpAuth)) {
switch ($httpAuth['httpAuthMethod']) {
case 'basic':
$request->setAuth($httpAuth['httpAuthUsername'], $httpAuth['httpAuthPassword'], \HTTP_Request2::AUTH_BASIC);
break;
case 'disgest':
$request->setAuth($httpAuth['httpAuthUsername'], $httpAuth['httpAuthPassword'], \HTTP_Request2::AUTH_DIGEST);
break;
case 'none':
default:
break;
}
}
foreach ($data as $name => $value) {
$request->addPostParameter($name, $value);
}
if (!empty($files)) {
foreach ($files as $fieldId => $file) {
$request->addUpload($fieldId, $file);
}
}
if ($this->sessionId !== null) {
$request->addCookie(session_name(), $this->sessionId);
}
$request->setConfig(array('ssl_verify_host' => false, 'ssl_verify_peer' => false, 'follow_redirects' => true, 'strict_redirects' => true));
$response = $request->send();
//echo '<pre>';var_dump($response->getBody());echo '<br /><br />';
$cookies = $response->getCookies();
foreach ($cookies as &$cookie) {
if ($cookie['name'] === session_name()) {
$this->sessionId = $cookie['value'];
break;
}
}
if ($response->getStatus() != 200) {
\DBG::msg(__METHOD__ . ' Request failed! Status: ' . $response->getStatus());
\DBG::msg('URL: ' . $url);
\DBG::dump($data);
return false;
}
$body = json_decode($response->getBody());
if ($body === NULL) {
\DBG::msg(__METHOD__ . ' failed!');
\DBG::dump($response->getBody());
}
return $body;
}