本文整理汇总了PHP中Pimcore_Resource类的典型用法代码示例。如果您正苦于以下问题:PHP Pimcore_Resource类的具体用法?PHP Pimcore_Resource怎么用?PHP Pimcore_Resource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Pimcore_Resource类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getDb
/**
* @return Zend_Db_Adapter_Abstract
*/
protected function getDb()
{
if (!$this->db) {
$this->db = Pimcore_Resource::get();
}
return $this->db;
}
示例2: httpErrorLogCleanup
/**
*
*/
public function httpErrorLogCleanup()
{
// keep the history for 14 days
$limit = time() - 14 * 86400;
$db = Pimcore_Resource::get();
$db->delete("http_error_log", "date < " . $limit);
}
示例3: installAction
public function installAction()
{
// try to establish a mysql connection
try {
$db = Zend_Db::factory($this->_getParam("mysql_adapter"), array('host' => $this->_getParam("mysql_host"), 'username' => $this->_getParam("mysql_username"), 'password' => $this->_getParam("mysql_password"), 'dbname' => $this->_getParam("mysql_database"), "port" => $this->_getParam("mysql_port")));
$db->getConnection();
// check utf-8 encoding
$result = $db->fetchRow('SHOW VARIABLES LIKE "character\\_set\\_database"');
if ($result['Value'] != "utf8") {
$errors[] = "Database charset is not utf-8";
}
} catch (Exception $e) {
$errors[] = "Couldn't establish connection to mysql: " . $e->getMessage();
}
// check username & password
if (strlen($this->_getParam("admin_password")) < 4 || strlen($this->_getParam("admin_username")) < 4) {
$errors[] = "Username and password should have at least 4 characters";
}
if (empty($errors)) {
// write configuration file
$settings = array("general" => array("timezone" => "Europe/Berlin", "language" => "en", "validLanguages" => "en", "debug" => "1", "theme" => "/pimcore/static/js/lib/ext/resources/css/xtheme-gray.css", "loginscreenimageservice" => "1", "welcomescreen" => "1", "loglevel" => array("debug" => "1", "info" => "1", "notice" => "1", "warning" => "1", "error" => "1", "critical" => "1", "alert" => "1", "emergency" => "1")), "database" => array("adapter" => $this->_getParam("mysql_adapter"), "params" => array("host" => $this->_getParam("mysql_host"), "username" => $this->_getParam("mysql_username"), "password" => $this->_getParam("mysql_password"), "dbname" => $this->_getParam("mysql_database"), "port" => $this->_getParam("mysql_port"))), "documents" => array("versions" => array("steps" => "10"), "default_controller" => "default", "default_action" => "default", "error_page" => "/", "allowtrailingslash" => "no", "allowcapitals" => "no"), "objects" => array("versions" => array("steps" => "10")), "assets" => array("versions" => array("steps" => "10")), "services" => array(), "cache" => array("excludeCookie" => "pimcore_admin_sid"), "httpclient" => array("adapter" => "Zend_Http_Client_Adapter_Socket"));
$config = new Zend_Config($settings, true);
$writer = new Zend_Config_Writer_Xml(array("config" => $config, "filename" => PIMCORE_CONFIGURATION_SYSTEM));
$writer->write();
// insert db dump
$db = Pimcore_Resource::get();
$mysqlInstallScript = file_get_contents(PIMCORE_PATH . "/modules/install/mysql/install.sql");
// remove comments in SQL script
$mysqlInstallScript = preg_replace("/\\s*(?!<\")\\/\\*[^\\*]+\\*\\/(?!\")\\s*/", "", $mysqlInstallScript);
// get every command as single part
$mysqlInstallScripts = explode(";", $mysqlInstallScript);
// execute every script with a separate call, otherwise this will end in a PDO_Exception "unbufferd queries, ..." seems to be a PDO bug after some googling
foreach ($mysqlInstallScripts as $m) {
$sql = trim($m);
if (strlen($sql) > 0) {
$sql .= ";";
$db->query($m);
}
}
// get a new database connection
$db = Pimcore_Resource::reset();
// insert data into database
$db->insert("assets", array("id" => 1, "parentId" => 0, "type" => "folder", "filename" => "", "path" => "/", "creationDate" => time(), "modificationDate" => time(), "userOwner" => 1, "userModification" => 1));
$db->insert("documents", array("id" => 1, "parentId" => 0, "type" => "page", "key" => "", "path" => "/", "index" => 999999, "published" => 1, "creationDate" => time(), "modificationDate" => time(), "userOwner" => 1, "userModification" => 1));
$db->insert("documents_page", array("id" => 1, "controller" => "", "action" => "", "template" => "", "title" => "", "description" => "", "keywords" => ""));
$db->insert("objects", array("o_id" => 1, "o_parentId" => 0, "o_type" => "folder", "o_key" => "", "o_path" => "/", "o_index" => 999999, "o_published" => 1, "o_creationDate" => time(), "o_modificationDate" => time(), "o_userOwner" => 1, "o_userModification" => 1));
$userPermissions = array(array("key" => "assets", "translation" => "permission_assets"), array("key" => "classes", "translation" => "permission_classes"), array("key" => "clear_cache", "translation" => "permission_clear_cache"), array("key" => "clear_temp_files", "translation" => "permission_clear_temp_files"), array("key" => "document_types", "translation" => "permission_document_types"), array("key" => "documents", "translation" => "permission_documents"), array("key" => "objects", "translation" => "permission_objects"), array("key" => "plugins", "translation" => "permission_plugins"), array("key" => "predefined_properties", "translation" => "permission_predefined_properties"), array("key" => "routes", "translation" => "permission_routes"), array("key" => "seemode", "translation" => "permission_seemode"), array("key" => "system_settings", "translation" => "permission_system_settings"), array("key" => "thumbnails", "translation" => "permission_thumbnails"), array("key" => "translations", "translation" => "permission_translations"), array("key" => "users", "translation" => "permission_users"), array("key" => "update", "translation" => "permissions_update"), array("key" => "redirects", "translation" => "permissions_redirects"), array("key" => "glossary", "translation" => "permissions_glossary"), array("key" => "reports", "translation" => "permissions_reports_marketing"));
foreach ($userPermissions as $up) {
$db->insert("users_permission_definitions", $up);
}
Pimcore::initConfiguration();
$user = User::create(array("parentId" => 0, "username" => $this->_getParam("admin_username"), "password" => Pimcore_Tool_Authentication::getPasswordHash($this->_getParam("admin_username"), $this->_getParam("admin_password")), "hasCredentials" => true, "active" => true));
$user->setAdmin(true);
$user->save();
$this->_helper->json(array("success" => true));
} else {
echo implode("<br />", $errors);
die;
}
}
示例4: __construct
public function __construct($classId, $idField = null, $storetable = null, $querytable = null, $relationtable = null)
{
$this->db = Pimcore_Resource::get();
$this->fields = array();
$this->relations = array();
$this->fieldIds = array();
if ($storetable == null) {
$this->storetable = self::STORE_TABLE . $classId;
} else {
$this->storetable = $storetable;
}
if ($querytable == null) {
$this->querytable = self::QUERY_TABLE . $classId;
} else {
$this->querytable = $querytable;
}
if ($relationtable == null) {
$this->relationtable = self::RELATION_TABLE . $classId;
} else {
$this->relationtable = $relationtable;
}
if ($idField == null) {
$this->idField = self::ID_FIELD;
} else {
$this->idField = $idField;
}
}
示例5: callResourceMethod
/**
* @param string $method
* @param array $args
* @return mixed
*/
public function callResourceMethod($method, $args)
{
$capture = false;
if (Pimcore::inAdmin()) {
$methodsToCheck = array("query", "update", "delete", "insert");
if (in_array($method, $methodsToCheck)) {
$capture = true;
Pimcore_Resource::startCapturingDefinitionModifications($method, $args);
}
}
//HACK - do not execute transaction methods when
//Zend_Registry::set('explicit_transactions', true) was set earlier in code
$transactionMethodsToCheck = array('beginTransaction', 'rollBack', 'commit');
try {
$explicitTransactions = Zend_Registry::get('explicit_transactions');
} catch (Exception $e) {
$explicitTransactions = false;
}
if (!$explicitTransactions || !in_array($method, $transactionMethodsToCheck)) {
$r = call_user_func_array(array($this->getResource(), $method), $args);
}
if (Pimcore::inAdmin() && $capture) {
Pimcore_Resource::stopCapturingDefinitionModifications();
}
return $r;
}
示例6: __call
/**
* @throws Exception
* @param $method
* @param $args
* @return mixed
*/
public function __call($method, $args)
{
try {
$r = $this->callResourceMethod($method, $args);
return $r;
} catch (Exception $e) {
return Pimcore_Resource::errorHandler($method, $args, $e);
}
}
示例7: sendQuery
function sendQuery($sql)
{
try {
$db = Pimcore_Resource::get();
$db->query($sql);
} catch (Exception $e) {
echo $e->getMessage();
echo "Please execute the following query manually: <br />";
echo "<pre>" . $sql . "</pre><hr />";
}
}
示例8: dispatchLoopShutdown
public function dispatchLoopShutdown()
{
$code = (string) $this->getResponse()->getHttpResponseCode();
if ($code && ($code[0] == "4" || $code[0] == "5")) {
$db = Pimcore_Resource::get();
try {
$db->insert("http_error_log", array("path" => $this->getRequest()->getPathInfo(), "code" => (int) $code, "parametersGet" => serialize($_GET), "parametersPost" => serialize($_POST), "cookies" => serialize($_COOKIE), "serverVars" => serialize($_SERVER), "date" => time()));
} catch (Exception $e) {
Logger::error("Unable to log http error");
Logger::error($e);
}
}
}
示例9: unitListAction
public function unitListAction()
{
$list = new \Pimcore\Model\Object\QuantityValue\Unit\Listing();
if ($this->_getParam("filter")) {
$array = explode(",", $this->_getParam("filter"));
$quotedArray = array();
$db = Pimcore_Resource::get();
foreach ($array as $a) {
$quotedArray[] = $db->quote($a);
}
$string = implode(",", $quotedArray);
$list->setCondition("id IN (" . $string . ")");
}
$units = $list->getUnits();
$this->_helper->json(array("data" => $units, "success" => true, "total" => $list->getTotalCount()));
}
示例10: cleanup
public static function cleanup()
{
// remove database tmp table
$db = Pimcore_Resource::get();
$db->query("DROP TABLE IF EXISTS `" . self::$tmpTable . "`");
//delete tmp data
recursiveDelete(PIMCORE_SYSTEM_TEMP_DIRECTORY . "/update", true);
}
示例11: update
/**
* Update question and answers.
* @return Poll_Question
* @throws Exception
*/
protected function update()
{
$db = Pimcore_Resource::getConnection()->getResource();
try {
$db->beginTransaction();
$answers = $this->getAnswers();
foreach ($answers as $key => $answer) {
if (in_array($answer->getId(), $this->_answersToDelete)) {
$answers->offsetUnset($key);
} else {
$answer->save();
}
}
if (count($answers) < 2) {
$this->setIsActive(false);
}
$this->getResource()->update();
$db->commit();
} catch (Exception $e) {
$db->rollBack();
throw $e;
}
return $this;
}
示例12: indexAction
public function indexAction()
{
$checksPHP = array();
$checksMySQL = array();
$checksFS = array();
// check for memory limit
$memoryLimit = ini_get("memory_limit");
$memoryLimit = filesize2bytes($memoryLimit . "B");
$state = "ok";
if ($memoryLimit < 134217728) {
$state = "error";
} else {
if ($memoryLimit < 268435456) {
$state = "warning";
}
}
$checksPHP[] = array("name" => "memory_limit (in php.ini)", "link" => "http://www.php.net/memory_limit", "state" => $state);
// check for safe_mode
$safemode = strtolower(ini_get("safe_mode"));
$checksPHP[] = array("name" => "safe_mode (in php.ini)", "link" => "http://www.php.net/safe_mode", "state" => $safemode == "on" ? "error" : "ok");
// mcrypt
$checksPHP[] = array("name" => "mcrypt", "link" => "http://www.php.net/mcrypt", "state" => function_exists("mcrypt_encrypt") ? "ok" : "error");
// pdo_mysql
$checksPHP[] = array("name" => "PDO_Mysql", "link" => "http://www.php.net/pdo_mysql", "state" => @constant("PDO::MYSQL_ATTR_FOUND_ROWS") ? "ok" : "error");
// pdo_mysql
$checksPHP[] = array("name" => "Mysqli", "link" => "http://www.php.net/mysqli", "state" => class_exists("mysqli") ? "ok" : "error");
// iconv
$checksPHP[] = array("name" => "iconv", "link" => "http://www.php.net/iconv", "state" => function_exists("iconv") ? "ok" : "error");
// dom
$checksPHP[] = array("name" => "dom", "link" => "http://www.php.net/dom", "state" => class_exists("DOMDocument") ? "ok" : "error");
// simplexml
$checksPHP[] = array("name" => "SimpleXML", "link" => "http://www.php.net/simplexml", "state" => class_exists("SimpleXMLElement") ? "ok" : "error");
// gd
$checksPHP[] = array("name" => "GD", "link" => "http://www.php.net/gd", "state" => function_exists("gd_info") ? "ok" : "error");
// multibyte support
$checksPHP[] = array("name" => "Multibyte String (mbstring)", "link" => "http://www.php.net/mbstring", "state" => function_exists("mb_get_info") ? "ok" : "error");
// zip
$checksPHP[] = array("name" => "zip", "link" => "http://www.php.net/zip", "state" => class_exists("ZipArchive") ? "ok" : "error");
// gzip
$checksPHP[] = array("name" => "zlib / gzip", "link" => "http://www.php.net/zlib", "state" => function_exists("gzcompress") ? "ok" : "error");
// bzip
$checksPHP[] = array("name" => "Bzip2", "link" => "http://www.php.net/bzip2", "state" => function_exists("bzcompress") ? "ok" : "error");
// openssl
$checksPHP[] = array("name" => "OpenSSL", "link" => "http://www.php.net/openssl", "state" => function_exists("openssl_open") ? "ok" : "error");
// Imagick
$checksPHP[] = array("name" => "Imagick", "link" => "http://www.php.net/imagick", "state" => class_exists("Imagick") ? "ok" : "warning");
// APC
$checksPHP[] = array("name" => "APC", "link" => "http://www.php.net/apc", "state" => function_exists("apc_add") ? "ok" : "warning");
// memcache
$checksPHP[] = array("name" => "Memcache", "link" => "http://www.php.net/memcache", "state" => class_exists("Memcache") ? "ok" : "warning");
// PCNTL
$checksPHP[] = array("name" => "PCNTL", "link" => "http://www.php.net/pcntl", "state" => function_exists("pcntl_exec") ? "ok" : "warning");
// soap
$checksPHP[] = array("name" => "Soap", "link" => "http://www.php.net/soap", "state" => class_exists("SoapClient") ? "ok" : "warning");
// curl for google api sdk
$checksPHP[] = array("name" => "curl", "link" => "http://www.php.net/curl", "state" => function_exists("curl_init") ? "ok" : "warning");
$db = null;
if ($this->_getParam("mysql_adapter")) {
// this is before installing
try {
$db = Zend_Db::factory($this->_getParam("mysql_adapter"), array('host' => $this->_getParam("mysql_host"), 'username' => $this->_getParam("mysql_username"), 'password' => $this->_getParam("mysql_password"), 'dbname' => $this->_getParam("mysql_database"), "port" => $this->_getParam("mysql_port")));
$db->getConnection();
} catch (Exception $e) {
$db = null;
}
} else {
// this is after installing, eg. after a migration, ...
$db = Pimcore_Resource::get();
}
if ($db) {
// storage engines
$engines = array();
$enginesRaw = $db->fetchAll("SHOW ENGINES;");
foreach ($enginesRaw as $engineRaw) {
$engines[] = strtolower($engineRaw["Engine"]);
}
// innodb
$checksMySQL[] = array("name" => "InnoDB Support", "state" => in_array("innodb", $engines) ? "ok" : "error");
// myisam
$checksMySQL[] = array("name" => "MyISAM Support", "state" => in_array("myisam", $engines) ? "ok" : "error");
// memory
$checksMySQL[] = array("name" => "MEMORY Support", "state" => in_array("memory", $engines) ? "ok" : "error");
// check database charset => utf-8 encoding
$result = $db->fetchRow('SHOW VARIABLES LIKE "character\\_set\\_database"');
$checksMySQL[] = array("name" => "Database Charset UTF8", "state" => $result['Value'] == "utf8" ? "ok" : "error");
// create table
$queryCheck = true;
try {
$db->query("CREATE TABLE __pimcore_req_check (\r\n id int(11) NOT NULL AUTO_INCREMENT,\r\n field varchar(255) CHARACTER SET latin1 NULL DEFAULT NULL,\r\n PRIMARY KEY (id)\r\n ) DEFAULT CHARSET=utf8 COLLATE utf8_general_ci");
} catch (Exception $e) {
$queryCheck = false;
}
$checksMySQL[] = array("name" => "CREATE TABLE", "state" => $queryCheck ? "ok" : "error");
// alter table
$queryCheck = true;
try {
$db->query("ALTER TABLE __pimcore_req_check ADD COLUMN alter_field varchar(255) NULL DEFAULT NULL");
} catch (Exception $e) {
$queryCheck = false;
}
//.........这里部分代码省略.........
示例13: addCollectionsAction
public function addCollectionsAction()
{
$ids = \Zend_Json::decode($this->_getParam("collectionIds"));
if ($ids) {
$db = Pimcore_Resource::get();
$query = "select * from classificationstore_groups g, classificationstore_collectionrelations c where colId IN (" . implode(",", $ids) . ") and g.id = c.groupId";
$mappedData = array();
$groupsData = $db->fetchAll($query);
foreach ($groupsData as $groupData) {
$mappedData[$groupData["id"]] = $groupData;
}
$groupIdList = array();
$allowedGroupIds = null;
if ($this->getParam("oid")) {
$object = Object_Concrete::getById($this->getParam("oid"));
$class = $object->getClass();
$fd = $class->getFieldDefinition($this->getParam("fieldname"));
$allowedGroupIds = $fd->getAllowedGroupIds();
}
foreach ($groupsData as $groupItem) {
$groupId = $groupItem["groupId"];
if (!$allowedGroupIds || $allowedGroupIds && in_array($groupId, $allowedGroupIds)) {
$groupIdList[] = $groupId;
}
}
$groupCondition = "id in (" . implode(",", $groupIdList) . ")";
$groupList = new Classificationstore\GroupConfig\Listing();
$groupList->setCondition($groupCondition);
// $groupList->setOrderKey(array("sorter", "id"));
// $groupList->setOrder(array("ASC", "ASC"));
$groupList = $groupList->load();
$keyCondition = "groupId in (" . implode(",", $groupIdList) . ")";
$keyList = new Classificationstore\KeyGroupRelation\Listing();
$keyList->setCondition($keyCondition);
$keyList->setOrderKey(array("sorter", "id"));
$keyList->setOrder(array("ASC", "ASC"));
$keyList = $keyList->load();
foreach ($groupList as $groupData) {
$data[$groupData->getId()] = array("name" => $groupData->getName(), "id" => $groupData->getId(), "description" => $groupData->getDescription(), "keys" => array(), "collectionId" => $mappedData[$groupId]["colId"]);
}
foreach ($keyList as $keyData) {
$groupId = $keyData->getGroupId();
$keyList = $data[$groupId]["keys"];
$definition = $keyData->getDefinition();
$keyList[] = array("name" => $keyData->getName(), "id" => $keyData->getKeyId(), "description" => $keyData->getDescription(), "definition" => json_decode($definition));
$data[$groupId]["keys"] = $keyList;
}
}
return $this->_helper->json($data);
}
示例14: portletModificationStatisticsAction
public function portletModificationStatisticsAction()
{
$db = Pimcore_Resource::get();
$days = 31;
$startDate = mktime(23, 59, 59, date("m"), date("d"), date("Y"));
$currentDate = $startDate;
$data = array();
for ($i = 0; $i < $days; $i++) {
// documents
$end = $startDate - $i * 86400;
$start = $end - 86399;
$o = $db->fetchRow("SELECT COUNT(*) AS count FROM objects WHERE o_modificationDate > " . $start . " AND o_modificationDate < " . $end);
$a = $db->fetchRow("SELECT COUNT(*) AS count FROM assets WHERE modificationDate > " . $start . " AND modificationDate < " . $end);
$d = $db->fetchRow("SELECT COUNT(*) AS count FROM documents WHERE modificationDate > " . $start . " AND modificationDate < " . $end);
$date = new Zend_Date($start);
$data[] = array("timestamp" => $start, "datetext" => $date->get(Zend_Date::DATE_LONG), "objects" => (int) $o["count"], "documents" => (int) $d["count"], "assets" => (int) $a["count"]);
}
$data = array_reverse($data);
//p_r($data);
//exit;
$this->_helper->json(array("data" => $data));
}
示例15: INT
<?php
// get db connection
$db = Pimcore_Resource::get();
try {
$db->query("CREATE TABLE `keyvalue_translator_configuration` (\r\n `id` INT(10) NOT NULL AUTO_INCREMENT,\r\n `name` VARCHAR(200) NULL DEFAULT NULL,\r\n `translator` VARCHAR(200) NULL DEFAULT NULL,\r\n PRIMARY KEY (`id`)\r\n ) DEFAULT CHARSET=utf8;");
} catch (\Exception $e) {
echo $e->getMessage();
}