Newer
Older
use QUI\Projects\Project;
use QUI\Projects\Site;
public function createBrickForProject(Project $Project, Brick $Brick)
{
QUI::getDataBase()->insert(
$this->_getTable(),
array(
'project' => $Project->getName(),
'title' => $Brick->getAttribute('title'),
'description' => $Brick->getAttribute('description'),
'type' => $Brick->getAttribute('type')
)
);
$lastId = QUI::getPDO()->lastInsertId();
return $lastId;
}
// check if brick exist
$this->getBrickById( $brickId );
/**
* Return the areas which are available in the project
*
* @param Project $Project
* @param string|bool $siteType - optional, returns only the areas for the specific site type (default = false)
public function getAreasByProject(Project $Project, $siteType=false)
$projectName = $Project->getName();
// get all vhosts, and the used templates of the project
$vhosts = QUI::getRewrite()->getVHosts();
foreach ( $vhosts as $vhost )
{
if ( !isset( $vhost['template'] ) ) {
continue;
}
if ( $vhost['project'] != $projectName ) {
continue;
}
$templates[] = $vhost['template'];
}
$brickXML = realpath( OPT_DIR . $template .'/bricks.xml' );
$bricks = array_merge(
$bricks,
Utils::getTemplateAreasFromXML( $brickXML, $siteType )
try
{
return QUI\Cache\Manager::get( $cache );
} catch ( QUI\Exception $Exception )
{
}
$PKM = QUI::getPackageManager();
$packages = $PKM->getInstalled();
$result = array();
'title' => array( 'quiqqer/bricks', 'brick.content.title' ),
'description' => array( 'quiqqer/bricks', 'brick.content.description' ),
$bricksXML = OPT_DIR . $package['name'] .'/bricks.xml';
$result = array_merge( $result, Utils::getBricksFromXML( $bricksXML ) );
QUI\Cache\Manager::set( $cache, $result );
return $result;
}
if ( isset( $this->_bricks[ $id ] ) ) {
return $this->_bricks[ $id ];
}
$data = QUI::getDataBase()->fetch(array(
'from' => $this->_getTable(),
'where' => array(
'id' => (int)$id
),
'limit' => 1
));
if ( !isset( $data[0] ) ) {
* @param Site $Site
* @return array
*/
public function getBricksByArea($brickArea, Site $Site)
$brickAreas = $Site->getAttribute( 'quiqqer.bricks.areas' );
$brickAreas = json_decode( $brickAreas, true );
return array();
}
$result = array();
} catch ( QUI\Exception $Exception )
{
return $result;
* Return a list with \QUI\Bricks\Brick which are assigned to a project
*
* @param Project $Project
* @return array
*/
{
$result = array();
$list = QUI::getDataBase()->fetch(array(
'from' => $this->_getTable(),
'where' => array(
'project' => $Project->getName()
)
));
foreach ( $list as $entry )
{
$Brick = new Brick( $entry );
$Brick->setAttribute( 'id', $entry['id'] );
* @param string|integer $brickId - Brick-ID
* @param array $brickData - Brick data
if ( isset( $brickData[ 'id' ] ) ) {
unset( $brickData[ 'id' ] );
}
// check areas
$Project = QUI::getProjectManager()->getProject(
);
$availableAreas = array_map(function($data)
{
if ( isset( $data[ 'name' ] ) ) {
return $data[ 'name' ];
}
return '';
}, $this->getAreasByProject( $Project ));
foreach ( $parts as $area )
{
if ( in_array( $area, $availableAreas ) ) {
$areas[] = $area;
}
}
}
if ( !empty( $areas ) ) {
$areaString = ','. implode( ',', $areas ) .',';
}
'title' => $Brick->getAttribute( 'title' ),
'description' => $Brick->getAttribute( 'description' ),
'content' => $Brick->getAttribute( 'content' ),
'type' => $Brick->getAttribute( 'type' ),
'settings' => json_encode( $Brick->getAttribute( 'settings' ) ),
* @return String
*/
protected function _getTable()
{
return QUI::getDBTableName( self::TABLE );
}