本文整理汇总了PHP中Kwc_Abstract::createModel方法的典型用法代码示例。如果您正苦于以下问题:PHP Kwc_Abstract::createModel方法的具体用法?PHP Kwc_Abstract::createModel怎么用?PHP Kwc_Abstract::createModel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Kwc_Abstract
的用法示例。
在下文中一共展示了Kwc_Abstract::createModel方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __get
public function __get($var)
{
if ($var == 'url') {
$m = Kwc_Abstract::createModel($this->componentClass);
$row = $m->getRow($this->dbId);
if (!$row) {
return null;
}
$fRow = $row->getParentRow('File');
if (!$fRow) {
return null;
}
$filename = $row->filename;
if (!$filename) {
$filename = $fRow->filename;
}
$filename .= '.' . $fRow->extension;
$ret = Kwf_Media::getUrl($this->componentClass, $this->componentId, 'default', $filename);
$ev = new Kwf_Component_Event_CreateMediaUrl($this->componentClass, $this, $ret);
Kwf_Events_Dispatcher::fireEvent($ev);
return $ev->url;
} else {
return parent::__get($var);
}
}
示例2: __get
public function __get($var)
{
if ($var == 'url') {
$m = Kwc_Abstract::createModel($this->componentClass);
$row = $m->getRow($this->dbId);
if (!$row || !$row->own_download) {
//not own_download but still output thru own url to be ablte to call own isValidMediaOutput
$row = $this->chained->getComponent()->getRow();
if (!$row) {
return null;
}
$fRow = $row->getParentRow('File');
if (!$fRow) {
return null;
}
$filename = $row->filename;
if (!$filename) {
$filename = $fRow->filename;
}
$filename .= '.' . $fRow->extension;
return Kwf_Media::getUrl($this->componentClass, $this->componentId, 'default', $filename);
}
return $this->getChildComponent('-download')->url;
} else {
return parent::__get($var);
}
}
示例3: getLinkedData
public final function getLinkedData()
{
if (!isset($this->_data)) {
$masterLinkData = $this->chained->getLinkedData(array('ignoreVisible' => true));
if (!$masterLinkData) {
$this->_data = false;
}
if ($masterLinkData) {
if (is_null($this->_type)) {
throw new Kwf_Exception("_type may not be null");
}
if ($this->_type == 'Trl') {
$linkComponent = Kwc_Chained_Trl_Component::getChainedByMaster($masterLinkData, $this);
} else {
if ($this->_type == 'Cc') {
$linkComponent = Kwc_Chained_Cc_Component::getChainedByMaster($masterLinkData, $this);
}
}
if (!$linkComponent) {
$this->_data = false;
//kann offline sein
} else {
$this->_data = $linkComponent;
}
}
}
$m = Kwc_Abstract::createModel($this->chained->componentClass);
$result = $m->fetchColumnsByPrimaryId(array('anchor'), $this->chained->dbId);
if ($result['anchor']) {
$this->_anchor = $result['anchor'];
}
return $this->_data;
}
示例4: _getData
protected function _getData($select = array())
{
$m = Kwc_Abstract::createModel($this->componentClass);
$newsId = $m->fetchColumnByPrimaryId('news_id', $this->dbId);
if ($newsId) {
return Kwf_Component_Data_Root::getInstance()->getComponentByDbId('news_' . $newsId, array('subroot' => $this));
}
return false;
}
示例5: __get
public function __get($var)
{
if ($var == 'url') {
$m = Kwc_Abstract::createModel($this->componentClass);
$row = $m->getRow($this->dbId);
if (!$row) {
return null;
}
$fRow = $row->getParentRow('File');
if (!$fRow) {
return null;
}
$filename = $row->filename;
if (!$filename) {
$filename = $fRow->filename;
}
$filename .= '.' . $fRow->extension;
return Kwf_Media::getUrl($this->componentClass, $this->componentId, 'default', $filename);
} else {
return parent::__get($var);
}
}
示例6: _getData
protected function _getData($select = array())
{
$m = Kwc_Abstract::createModel($this->componentClass);
$result = $m->fetchColumnsByPrimaryId(array('target', 'anchor'), $this->dbId);
if ($result) {
$ret = null;
$s = $select;
$s['subroot'] = $this;
$s['limit'] = 1;
$components = Kwf_Component_Data_Root::getInstance()->getComponentsByDbId($result['target'], $s);
if ($components) {
$ret = $components[0];
}
if (!$ret) {
$ret = Kwf_Component_Data_Root::getInstance()->getComponentByDbId($result['target'], $select);
}
if ($result['anchor']) {
$this->_anchor = $result['anchor'];
}
return $ret;
}
return false;
}
示例7: startElement
protected function startElement($parser, $element, $attributes)
{
$finalHTML = $this->_finalHTML;
if ($element == 'SPAN') {
if (isset($attributes['STYLE'])) {
$style = $attributes['STYLE'];
} else {
$style = '';
}
if (preg_match('# *font-weight *: *bold *; *#', $style, $matches)) {
array_push($this->_stack, 'strong');
$this->_finalHTML .= '<strong>';
} elseif (preg_match('# *font-style *: *italic *; *#', $style, $matches)) {
array_push($this->_stack, 'em');
$this->_finalHTML .= '<em>';
} elseif (preg_match('# *text-decoration *: *underline *; *#', $style, $matches)) {
array_push($this->_stack, 'u');
$this->_finalHTML .= '<u>';
} elseif (preg_match('# *color *: *[0-9A-Za-z]* *#', $style, $matches) && $this->_enableColor) {
array_push($this->_stack, 'span');
$this->_finalHTML .= '<span style="' . $style . '">';
} elseif (preg_match('# *background-color *: *[0-9A-Za-z]* *#', $style, $matches) && $this->_enableColor) {
array_push($this->_stack, 'span');
$this->_finalHTML .= '<span style="' . $style . '">';
} else {
$allowedClasses = array();
foreach ($this->_getMasterStyles() as $s) {
if ($s['tagName'] == strtolower($element)) {
$allowedClasses[] = $s['className'];
}
}
if ($this->_enableCursorSpan && isset($attributes['CLASS']) && $attributes['CLASS'] == '_mce_type-bookmark') {
array_push($this->_stack, 'span');
$this->_finalHTML .= '<span class="' . $attributes['CLASS'] . '"';
if (isset($attributes['STYLE'])) {
$this->_finalHTML .= ' style="' . $attributes['STYLE'] . '"';
}
if (isset($attributes['ID'])) {
$this->_finalHTML .= ' id="' . $attributes['ID'] . '"';
}
$this->_finalHTML .= '>';
} else {
if ($this->_enableStyles && isset($attributes['CLASS']) && (preg_match('#^style[0-9]+$#', $attributes['CLASS']) || in_array($attributes['CLASS'], $allowedClasses))) {
array_push($this->_stack, 'span');
$this->_finalHTML .= '<span class="' . $attributes['CLASS'] . '">';
} else {
array_push($this->_stack, false);
}
}
}
} elseif ($element == 'BODY' || $element == 'O:P') {
array_push($this->_stack, false);
//do nothing
} elseif ($element == 'SCRIPT') {
array_push($this->_stack, false);
$this->_deleteContent++;
} else {
if ($element == 'IMG') {
$src = $attributes['SRC'];
$id = preg_quote($this->_dbId);
if (preg_match('#/media/([^/]+)/(' . $id . '-i[0-9]+)#', $src, $m)) {
//"/media/$class/$id/$type/$checksum/$filename.$extension$random"
$class = Kwc_Abstract::getChildComponentClass($this->_model->getComponentClass(), 'child', 'image');
$imageRow = Kwc_Abstract::createModel($class)->getRow($m[2]);
if (isset($attributes['WIDTH']) && $imageRow) {
$imageRow->width = $attributes['WIDTH'];
}
if (isset($attributes['HEIGHT']) && $imageRow) {
$imageRow->height = $attributes['HEIGHT'];
}
if (isset($attributes['STYLE']) && $imageRow) {
if (preg_match('#[^a-zA-Z\\-]*width: *([0-9]+)px#', $attributes['STYLE'], $m)) {
$imageRow->width = $m[1];
}
if (preg_match('#[^a-zA-Z\\-]*height: *([0-9]+)px#', $attributes['STYLE'], $m)) {
$imageRow->height = $m[1];
}
}
if ($imageRow) {
$imageRow->save();
$attributes['WIDTH'] = $imageRow->width;
$attributes['HEIGHT'] = $imageRow->height;
if (isset($attributes['STYLE'])) {
unset($attributes['STYLE']);
}
}
}
}
if ($this->_enableTagsWhitelist && !in_array(strtolower($element), array_keys($this->_tagsWhitelist))) {
//ignore this tag
array_push($this->_stack, false);
} else {
$this->_finalHTML .= '<' . strtolower($element);
foreach ($attributes as $key => $value) {
if (in_array(strtolower($key), $this->_tagsWhitelist[strtolower($element)])) {
$allowedClasses = array();
foreach ($this->_getMasterStyles() as $s) {
if ($s['tagName'] == strtolower($element)) {
$allowedClasses[] = $s['className'];
}
//.........这里部分代码省略.........
示例8: tidy
public function tidy($html, Kwc_Basic_Text_Parser $parser = null)
{
//convert umlauts from NFD to NFC
$html = str_replace('u' . chr(0xcc) . chr(0x88), 'ü', $html);
$html = str_replace('a' . chr(0xcc) . chr(0x88), 'ä', $html);
$html = str_replace('o' . chr(0xcc) . chr(0x88), 'ö', $html);
$html = str_replace('U' . chr(0xcc) . chr(0x88), 'Ü', $html);
$html = str_replace('A' . chr(0xcc) . chr(0x88), 'Ä', $html);
$html = str_replace('O' . chr(0xcc) . chr(0x88), 'Ö', $html);
//delete zero width space, causes problems in Lotus Notes
$html = str_replace(chr(0xe2) . chr(0x80) . chr(0x8b), '', $html);
//delete BOM that might have sneaked into the text (at any position)
$html = str_replace(chr(0xef) . chr(0xbb) . chr(0xbf), '', $html);
$enableTidy = Kwc_Abstract::getSetting($this->_componentClass, 'enableTidy');
$enableFontSize = Kwc_Abstract::getSetting($this->_componentClass, 'enableFontSize');
$config = array();
if (!$enableFontSize) {
$config['drop-font-tags'] = true;
}
if ($enableTidy) {
//woraround für tidy bug wo er zwei class-attribute in einen
//tag schreibt wenn eins davon leer ist
//siehe Kwc_Basic_Text_ModelContentTest::testTidyRemovesSomeText
//einfach leere klassen löschen
$html = preg_replace('#<(.[a-z]+) ([^>]*)class=""([^>]*)>#', '<\\1 \\2 \\3>', $html);
//html kommentare löschen, löscht auch word schas mit
$html = preg_replace('#<!--.*?-->#s', '', $html);
$html = str_replace('data-mce-type="bookmark"', 'class="_mce_type-bookmark"', $html);
$html = str_replace(' ', '#nbsp#', $html);
//einstellungen oben funktionieren nicht richtig
$html = Kwf_Util_Tidy::repairHtml($html, $config);
if (!$parser) {
$parser = new Kwc_Basic_Text_Parser($this->componentId, $this->getModel());
$parser->setMasterStyles(Kwc_Basic_Text_StylesModel::getMasterStyles());
}
$parser->setEnableColor(Kwc_Abstract::getSetting($this->_componentClass, 'enableColors'));
$parser->setEnableTagsWhitelist(Kwc_Abstract::getSetting($this->_componentClass, 'enableTagsWhitelist'));
$parser->setEnableStyles(Kwc_Abstract::getSetting($this->_componentClass, 'enableStyles'));
$html = $parser->parse($html);
$html = Kwf_Util_Tidy::repairHtml($html, $config);
$html = str_replace('class="_mce_type-bookmark"', 'data-mce-type="bookmark"', $html);
$html = str_replace('#nbsp#', ' ', $html);
}
$classes = $this->_classes;
$newContent = '';
foreach ($this->getContentParts($html) as $part) {
if (is_string($part)) {
$newContent .= $part;
} else {
if ($part['type'] == 'invalidImage') {
if (isset($part['componentId']) && class_exists($part['componentClass']) && (strtolower($part['componentClass']) == 'kwc_basic_image_component' || is_subclass_of($part['componentClass'], 'Kwc_Basic_Image_Component'))) {
$srcRow = Kwc_Abstract::createModel($part['componentClass'])->getRow($part['componentId']);
if ($srcRow->imageExists()) {
$destRow = Kwc_Abstract::createModel($classes['image'])->createRow($srcRow->toArray());
$childComponentRow = $this->addChildComponentRow('image', $destRow);
$destRow->save();
$imageComponent = Kwf_Component_Data_Root::getInstance()->getComponentByDbId($this->component_id . '-i' . $childComponentRow->nr)->getComponent();
$dimension = $imageComponent->getImageDimensions();
$newContent .= "<img src=\"" . $imageComponent->getImageUrl() . "\" " . "width=\"{$dimension['width']}\" " . "height=\"{$dimension['height']}\" />";
continue;
}
}
$client = new Zend_Http_Client();
try {
$client->setUri($part['src']);
} catch (Zend_Uri_Exception $e) {
//wann relative url mit http_host davor probieren
if (isset($_SERVER['HTTP_HOST'])) {
$client->setUri('http://' . $_SERVER['HTTP_HOST'] . '/' . $part['src']);
}
}
try {
$response = $client->request();
} catch (Exception $e) {
continue;
}
if (!$response->isSuccessful()) {
continue;
}
$contentType = $response->getHeader('Content-type');
if ($contentType == 'image/jpg' || $contentType == 'image/jpeg') {
$extension = 'jpg';
} else {
if ($contentType == 'image/gif') {
$extension = 'gif';
} else {
if ($contentType == 'image/png') {
$extension = 'png';
} else {
continue;
}
}
}
$destFileRow = Kwc_Abstract::createModel($classes['image'])->getReferencedModel('Image')->createRow();
$path = explode('?', $part['src']);
if (preg_match('#([^/]*)\\.[a-z]+$#U', $path[0], $m)) {
$srcFileName = Zend_Filter::filterStatic($m[1], 'Alnum', array(ENT_QUOTES));
}
if (!isset($srcFileName) || !$srcFileName) {
$srcFileName = 'download';
//.........这里部分代码省略.........