本文整理汇总了PHP中Pimcore_Resource::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Pimcore_Resource::get方法的具体用法?PHP Pimcore_Resource::get怎么用?PHP Pimcore_Resource::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pimcore_Resource
的用法示例。
在下文中一共展示了Pimcore_Resource::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __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;
}
}
示例2: 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;
}
}
示例3: 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);
}
示例4: getDb
/**
* @return Zend_Db_Adapter_Abstract
*/
protected function getDb()
{
if (!$this->db) {
$this->db = Pimcore_Resource::get();
}
return $this->db;
}
示例5: 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 />";
}
}
示例6: 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);
}
}
}
示例7: load
/**
* @param Object_Concrete|Object_Fieldcollection_Data_Abstract|Object_Localizedfield $object
* @return null | array
*/
public function load($object, $params = array())
{
$db = Pimcore_Resource::get();
$data = null;
if ($object instanceof Object_Concrete) {
if (!method_exists($this, "getLazyLoading") or !$this->getLazyLoading() or $params["force"]) {
$relations = $db->fetchAll("SELECT * FROM object_relations_" . $object->getClassId() . " WHERE src_id = ? AND fieldname = ? AND ownertype = 'object'", array($object->getO_id(), $this->getName()));
} else {
return null;
}
} else {
if ($object instanceof Object_Fieldcollection_Data_Abstract) {
$relations = $db->fetchAll("SELECT * FROM object_relations_" . $object->getObject()->getClassId() . " WHERE src_id = ? AND fieldname = ? AND ownertype = 'fieldcollection' AND ownername = ? AND position = ?", array($object->getObject()->getId(), $this->getName(), $object->getFieldname(), $object->getIndex()));
} else {
if ($object instanceof Object_Localizedfield) {
$relations = $db->fetchAll("SELECT * FROM object_relations_" . $object->getObject()->getClassId() . " WHERE src_id = ? AND fieldname = ? AND ownertype = 'localizedfield' AND ownername = 'localizedfield' AND position = ?", array($object->getObject()->getId(), $this->getName(), $params["language"]));
} else {
if ($object instanceof Object_Objectbrick_Data_Abstract) {
$relations = $db->fetchAll("SELECT * FROM object_relations_" . $object->getObject()->getClassId() . " WHERE src_id = ? AND fieldname = ? AND ownertype = 'objectbrick' AND ownername = ? AND position = ?", array($object->getObject()->getId(), $this->getName(), $object->getFieldname(), $object->getType()));
// THIS IS KIND A HACK: it's necessary because of this bug PIMCORE-1454 and therefore cannot be removed
if (count($relations) < 1) {
$relations = $db->fetchAll("SELECT * FROM object_relations_" . $object->getObject()->getClassId() . " WHERE src_id = ? AND fieldname = ? AND ownertype = 'objectbrick' AND ownername = ? AND (position IS NULL OR position = '')", array($object->getObject()->getId(), $this->getName(), $object->getFieldname()));
}
// HACK END
}
}
}
}
// using PHP sorting to order the relations, because "ORDER BY index ASC" in the queries above will cause a
// filesort in MySQL which is extremly slow especially when there are millions of relations in the database
usort($relations, function ($a, $b) {
if ($a["index"] == $b["index"]) {
return 0;
}
return $a["index"] < $b["index"] ? -1 : 1;
});
$data = $this->getDataFromResource($relations);
return $data;
}
示例8: 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);
}
示例9: 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);
}
示例10: quote
/**
* @param $value
* @return void
*/
public function quote($value, $type = null)
{
$db = Pimcore_Resource::get();
return $db->quote($value, $type);
}
示例11: getFilterCondition
/**
*
* @param string $filterJson
* @param Object_Class $class
* @return string
*/
public static function getFilterCondition($filterJson, $class)
{
$systemFields = array("o_path", "o_key", "o_id", "o_published", "o_creationDate", "o_modificationDate");
// create filter condition
$conditionPartsFilters = array();
if ($filterJson) {
$filters = Zend_Json::decode($filterJson);
foreach ($filters as $filter) {
$operator = "=";
if ($filter["type"] == "string") {
$operator = "LIKE";
} else {
if ($filter["type"] == "numeric") {
if ($filter["comparison"] == "lt") {
$operator = "<";
} else {
if ($filter["comparison"] == "gt") {
$operator = ">";
} else {
if ($filter["comparison"] == "eq") {
$operator = "=";
}
}
}
} else {
if ($filter["type"] == "date") {
if ($filter["comparison"] == "lt") {
$operator = "<";
} else {
if ($filter["comparison"] == "gt") {
$operator = ">";
} else {
if ($filter["comparison"] == "eq") {
$operator = "=";
}
}
}
$filter["value"] = strtotime($filter["value"]);
} else {
if ($filter["type"] == "list") {
$operator = "=";
} else {
if ($filter["type"] == "boolean") {
$operator = "=";
$filter["value"] = (int) $filter["value"];
}
}
}
}
}
$field = $class->getFieldDefinition($filter["field"]);
$brickField = null;
$brickType = null;
if (!$field) {
// if the definition doesn't exist check for a localized field
$localized = $class->getFieldDefinition("localizedfields");
if ($localized instanceof Object_Class_Data_Localizedfields) {
$field = $localized->getFieldDefinition($filter["field"]);
}
//if the definition doesn't exist check for object brick
$keyParts = explode("~", $filter["field"]);
if (count($keyParts) > 1) {
$brickType = $keyParts[0];
$brickKey = $keyParts[1];
$key = self::getFieldForBrickType($class, $brickType);
$field = $class->getFieldDefinition($key);
$brickClass = Object_Objectbrick_Definition::getByKey($brickType);
$brickField = $brickClass->getFieldDefinition($brickKey);
}
}
if ($field instanceof Object_Class_Data_Objectbricks) {
// custom field
$db = Pimcore_Resource::get();
if (is_array($filter["value"])) {
$fieldConditions = array();
foreach ($filter["value"] as $filterValue) {
$fieldConditions[] = $db->getQuoteIdentifierSymbol() . $brickType . $db->getQuoteIdentifierSymbol() . "." . $brickField->getFilterCondition($filterValue, $operator);
}
$conditionPartsFilters[] = "(" . implode(" OR ", $fieldConditions) . ")";
} else {
$conditionPartsFilters[] = $db->getQuoteIdentifierSymbol() . $brickType . $db->getQuoteIdentifierSymbol() . "." . $brickField->getFilterCondition($filter["value"], $operator);
}
} else {
if ($field instanceof Object_Class_Data) {
// custom field
if (is_array($filter["value"])) {
$fieldConditions = array();
foreach ($filter["value"] as $filterValue) {
$fieldConditions[] = $field->getFilterCondition($filterValue, $operator);
}
$conditionPartsFilters[] = "(" . implode(" OR ", $fieldConditions) . ")";
} else {
$conditionPartsFilters[] = $field->getFilterCondition($filter["value"], $operator);
}
//.........这里部分代码省略.........
示例12: httpErrorLogDetailAction
public function httpErrorLogDetailAction()
{
$db = Pimcore_Resource::get();
$data = $db->fetchRow("SELECT * FROM http_error_log WHERE id = ?", array($this->_getParam("id")));
foreach ($data as $key => &$value) {
if (in_array($key, array("parametersGet", "parametersPost", "serverVars", "cookies"))) {
$value = unserialize($value);
}
}
$this->view->data = $data;
}
示例13: findAction
/**
* @return void
*/
public function findAction()
{
$user = $this->getUser();
$query = $this->_getParam("query");
if ($query == "*") {
$query = "";
}
$query = str_replace("%", "*", $query);
$types = explode(",", $this->_getParam("type"));
$subtypes = explode(",", $this->_getParam("subtype"));
$classnames = explode(",", $this->_getParam("class"));
$offset = intval($this->_getParam("start"));
$limit = intval($this->_getParam("limit"));
$offset = $offset ? $offset : 0;
$limit = $limit ? $limit : 50;
$searcherList = new Search_Backend_Data_List();
$conditionParts = array();
$db = Pimcore_Resource::get();
//exclude forbidden assets
if (in_array("asset", $types)) {
if (!$user->isAllowed("assets")) {
$forbiddenConditions[] = " `type` != 'asset' ";
} else {
$forbiddenAssetPaths = Element_Service::findForbiddenPaths("asset", $user);
if (count($forbiddenAssetPaths) > 0) {
for ($i = 0; $i < count($forbiddenAssetPaths); $i++) {
$forbiddenAssetPaths[$i] = " (maintype = 'asset' AND fullpath not like " . $db->quote($forbiddenAssetPaths[$i] . "%") . ")";
}
$forbiddenConditions[] = implode(" AND ", $forbiddenAssetPaths);
}
}
}
//exclude forbidden documents
if (in_array("document", $types)) {
if (!$user->isAllowed("documents")) {
$forbiddenConditions[] = " `type` != 'document' ";
} else {
$forbiddenDocumentPaths = Element_Service::findForbiddenPaths("document", $user);
if (count($forbiddenDocumentPaths) > 0) {
for ($i = 0; $i < count($forbiddenDocumentPaths); $i++) {
$forbiddenDocumentPaths[$i] = " (maintype = 'document' AND fullpath not like " . $db->quote($forbiddenDocumentPaths[$i] . "%") . ")";
}
$forbiddenConditions[] = implode(" AND ", $forbiddenDocumentPaths);
}
}
}
//exclude forbidden objects
if (in_array("object", $types)) {
if (!$user->isAllowed("objects")) {
$forbiddenConditions[] = " `type` != 'object' ";
} else {
$forbiddenObjectPaths = Element_Service::findForbiddenPaths("object", $user);
if (count($forbiddenObjectPaths) > 0) {
for ($i = 0; $i < count($forbiddenObjectPaths); $i++) {
$forbiddenObjectPaths[$i] = " (maintype = 'object' AND fullpath not like " . $db->quote($forbiddenObjectPaths[$i] . "%") . ")";
}
$forbiddenConditions[] = implode(" AND ", $forbiddenObjectPaths);
}
}
}
if ($forbiddenConditions) {
$conditionParts[] = "(" . implode(" AND ", $forbiddenConditions) . ")";
}
if (!empty($query)) {
$queryCondition = "( MATCH (`data`,`properties`) AGAINST (" . $db->quote($query) . " IN BOOLEAN MODE) )";
// the following should be done with an exact-search now "ID", because the Element-ID is now in the fulltext index
// if the query is numeric the user might want to search by id
//if(is_numeric($query)) {
//$queryCondition = "(" . $queryCondition . " OR id = " . $db->quote($query) ." )";
//}
$conditionParts[] = $queryCondition;
}
//For objects - handling of bricks
$fields = array();
$bricks = array();
if ($this->_getParam("fields")) {
$fields = $this->_getParam("fields");
foreach ($fields as $f) {
$parts = explode("~", $f);
if (count($parts) > 1) {
$bricks[$parts[0]] = $parts[0];
}
}
}
// filtering for objects
if ($this->_getParam("filter")) {
$class = Object_Class::getByName($this->_getParam("class"));
$conditionFilters = Object_Service::getFilterCondition($this->_getParam("filter"), $class);
$join = "";
foreach ($bricks as $ob) {
$join .= " LEFT JOIN object_brick_query_" . $ob . "_" . $class->getId();
$join .= " `" . $ob . "`";
$join .= " ON `" . $ob . "`.o_id = `object_" . $class->getId() . "`.o_id";
}
$conditionParts[] = "( id IN (SELECT `object_" . $class->getId() . "`.o_id FROM object_" . $class->getId() . $join . " WHERE 1=1 " . $conditionFilters . ") )";
}
if (is_array($types) and !empty($types[0])) {
//.........这里部分代码省略.........
示例14: load
/**
* @param Object_Concrete|Object_Fieldcollection_Data_Abstract|Object_Localizedfield $object
* @return null | array
*/
public function load($object, $params = array())
{
$db = Pimcore_Resource::get();
if ($object instanceof Object_Concrete) {
if (!method_exists($this, "getLazyLoading") or !$this->getLazyLoading() or $params["force"]) {
$relations = $db->fetchAll("SELECT * FROM object_relations_" . $object->getClassId() . " WHERE src_id = ? AND fieldname = ? AND ownertype = 'object' ORDER BY `index` ASC", array($object->getO_id(), $this->getName()));
return $this->getDataFromResource($relations);
} else {
return null;
}
} else {
if ($object instanceof Object_Fieldcollection_Data_Abstract) {
$relations = $db->fetchAll("SELECT * FROM object_relations_" . $object->getObject()->getClassId() . " WHERE src_id = ? AND fieldname = ? AND ownertype = 'fieldcollection' AND ownername = ? AND position = ? ORDER BY `index` ASC", array($object->getObject()->getId(), $this->getName(), $object->getFieldname(), $object->getIndex()));
return $this->getDataFromResource($relations);
} else {
if ($object instanceof Object_Localizedfield) {
$relations = $db->fetchAll("SELECT * FROM object_relations_" . $object->getObject()->getClassId() . " WHERE src_id = ? AND fieldname = ? AND ownertype = 'localizedfield' AND ownername = 'localizedfield' AND position = ? ORDER BY `index` ASC", array($object->getObject()->getId(), $this->getName(), $params["language"]));
return $this->getDataFromResource($relations);
} else {
if ($object instanceof Object_Objectbrick_Data_Abstract) {
$relations = $db->fetchAll("SELECT * FROM object_relations_" . $object->getObject()->getClassId() . " WHERE src_id = ? AND fieldname = ? AND ownertype = 'objectbrick' AND ownername = ? ORDER BY `index` ASC", array($object->getObject()->getId(), $this->getName(), $object->getFieldname()));
return $this->getDataFromResource($relations);
}
}
}
}
}
示例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();
}