public static function home()
 {
     require_once 'Goals.model.php';
     require_once 'Content.model.php';
     $contentMdl = new ContentModel();
     $data = array('templates' => array('header.html', 'menu.html', 'searchForm.html', 'content.html', 'footer.html'), 'content' => $contentMdl->viewContent(), 'userID' => $_SESSION['userID'], 'user' => $_SESSION['username'], 'userLevel' => $_SESSION['userLevel'], 'viewRating' => $contentMdl->viewRating());
     return $data;
 }
 public static function search()
 {
     // sends info to search method in content.model on what to search for
     require_once 'Content.model.php';
     $contentMdl = new ContentModel();
     $data = array('templates' => array('header.html', 'menu.html', 'searchForm.html', 'content.html', 'footer.html'), 'content' => $contentMdl->searchContent($_POST['search'], $_POST['searchSubject'], $_POST['searchYear']), 'userLevel' => $_SESSION['userLevel'], 'user' => $_SESSION['username'], 'userID' => $_SESSION['userID']);
     return $data;
 }
Esempio n. 3
0
 /**
  * Initialize the object
  *
  * @param ContentModel|ModuleModel|FormModel $objElement
  * @param string                             $strColumn
  */
 public function __construct($objElement, $strColumn = 'main')
 {
     parent::__construct();
     // Store the parent element (see #4556)
     if ($objElement instanceof Model) {
         $this->objParent = $objElement;
     } elseif ($objElement instanceof Model\Collection) {
         $this->objParent = $objElement->current();
     }
     if ($this->strKey == '' || $this->strTable == '') {
         return;
     }
     /** @var Model $strModelClass */
     $strModelClass = \Model::getClassFromTable($this->strTable);
     // Load the model
     if (class_exists($strModelClass)) {
         $objHybrid = $strModelClass::findByPk($objElement->{$this->strKey});
         if ($objHybrid === null) {
             return;
         }
         $this->objModel = $objHybrid;
     } else {
         $objHybrid = $this->Database->prepare("SELECT * FROM " . $this->strTable . " WHERE id=?")->limit(1)->execute($objElement->{$this->strKey});
         if ($objHybrid->numRows < 1) {
             return;
         }
     }
     $cssID = array();
     $this->arrData = $objHybrid->row();
     // Get the CSS ID from the parent element (!)
     $this->cssID = deserialize($objElement->cssID, true);
     if (isset($objHybrid->attributes)) {
         $cssID = deserialize($objHybrid->attributes, true);
     }
     // Override the CSS ID (see #305)
     if (!empty($this->cssID[0])) {
         $cssID[0] = $this->cssID[0];
     }
     // Merge the CSS classes (see #6011)
     if (!empty($this->cssID[1])) {
         $cssID[1] = trim($cssID[1] . ' ' . $this->cssID[1]);
     }
     $this->cssID = $cssID;
     $this->typePrefix = $objElement->typePrefix;
     $arrHeadline = deserialize($objElement->headline);
     $this->headline = is_array($arrHeadline) ? $arrHeadline['value'] : $arrHeadline;
     $this->hl = is_array($arrHeadline) ? $arrHeadline['unit'] : 'h1';
     $this->strColumn = $strColumn;
 }
Esempio n. 4
0
 public function del()
 {
     if (IS_POST) {
         $uid = Q('uid', 0, 'intval');
         //删除文章
         if (Q('post.delcontent')) {
             $ModelCache = cache('model');
             foreach ($ModelCache as $model) {
                 $contentModel = ContentModel::getInstance($model['mid']);
                 $contentModel->where(array('uid' => $uid))->del();
             }
         }
         //删除评论
         if (Q('post.delcomment')) {
             M('comment')->where(array('uid' => $uid))->del();
         }
         //删除附件
         if (Q('post.delupload')) {
             M('upload')->where(array('uid' => $uid))->del();
         }
         //删除用户
         M('user')->del($uid);
         $this->success('删除成功...');
     } else {
         $uid = Q("uid", 0, "intval");
         $field = M('user')->find($uid);
         $this->assign('field', $field);
         $this->display();
     }
 }
 protected function createContentElements(&$objItem)
 {
     if ($objItem->tl_content) {
         // need to wrap <p> around text for contao
         $tidyConfig = array('enclose-text' => true, 'drop-font-tags' => true, 'drop-proprietary-attributes' => true, 'quote-ampersand' => true, 'clean' => false);
         $bodyText = '<!DOCTYPE html><head><title></title></head><body>' . $objItem->tl_content . '</body></html>';
         //			$bodyText = $this->convert_external_link_tags($bodyText);
         //			$bodyText = $this->convert_internal_link_tags($bodyText);
         $bodyText = $this->nl2p($bodyText);
         $tidy = new \tidy();
         $tidy->parseString($bodyText, $tidyConfig, $GLOBALS['TL_CONFIG']['dbCharset']);
         $body = $tidy->body();
         $objContent = new \ContentModel();
         $objContent->text = trim(str_replace(array('<body>', '</body>'), '', $body));
         $objContent->text = preg_replace("/<img[^>]+\\>/i", "", $objContent->text);
         // strip images
         // create links from text
         $objContent->text = preg_replace('!(\\s|^)((https?://|www\\.)+[a-z0-9_./?=&-]+)!i', ' <a href="http://$2" target="_blank">$2</a>', $objContent->text);
         // replace <b> by <strong>
         $objContent->text = preg_replace('!<b(.*?)>(.*?)</b>!i', '<strong>$2</strong>', $objContent->text);
         // replace emails with inserttags
         $objContent->text = preg_replace('/([A-Z0-9._%+-]+)@([A-Z0-9.-]+)\\.([A-Z]{2,4})(\\((.+?)\\))?/i', "{{email::\$1@\$2.\$3}}", $objContent->text);
         // strip not allowed tags
         $objContent->text = strip_tags($objContent->text, \Config::get('allowedTags'));
         $objContent->text = $this->stripAttributes($objContent->text, array('style', 'class', 'id'));
         $objContent->ptable = static::$strTable;
         $objContent->pid = $objItem->id;
         $objContent->sorting = 16;
         $objContent->tstamp = time();
         $objContent->type = 'text';
         $objContent->save();
     }
 }
    /**
     * Add the type of input field
     * @param array
     * @return string
     */
    public function listNewsletterArticles($arrRow)
    {
        $strStats = '';
        $strContents = '';
        $objContents = \ContentModel::findPublishedByPidAndTable($arrRow['id'], 'tl_newsletter');
        if (!is_null($objContents)) {
            foreach ($objContents as $objContent) {
                $strContents .= $this->getContentElement($objContent->id) . '<hr>';
            }
        }
        $intTotal = $arrRow['recipients'] + $arrRow['rejected'];
        //		$intTracked = NewsletterContent\Models\NewsletterTrackingModel::countTrackedByPid($arrRow['id']);
        $objTracked = NewsletterContent\Models\NewsletterTrackingModel::findTrackedInteractionsByPid($arrRow['id']);
        $intTracked = !is_null($objTracked) ? $objTracked->count() : 0;
        $intPercent = @round($intTracked / $intTotal * 100);
        $strStats = sprintf($GLOBALS['TL_LANG']['tl_newsletter']['sentTo'], $arrRow['recipients'], strval($intTotal), strval($intTracked), strval($intPercent));
        return '
<div class="cte_type ' . ($arrRow['sent'] && $arrRow['date'] ? 'published' : 'unpublished') . '"><strong>' . $arrRow['subject'] . '</strong> - ' . ($arrRow['sent'] && $arrRow['date'] ? sprintf($GLOBALS['TL_LANG']['tl_newsletter']['sentOn'], Date::parse($GLOBALS['TL_CONFIG']['datimFormat'], $arrRow['date'])) . '<br>' . $strStats : $GLOBALS['TL_LANG']['tl_newsletter']['notSent']) . '</div>
<div class="limit_height' . (!$GLOBALS['TL_CONFIG']['doNotCollapse'] ? ' h128' : '') . '">
' . (!$arrRow['sendText'] && strlen($strContents) ? '
' . $strContents : '') . '
' . nl2br_html5($arrRow['text']) . '
</div>' . "\n";
        return '<div class="tl_content_left">' . $arrRow['subject'] . ' <span style="color:#b3b3b3;padding-left:3px">[' . $arrRow['senderName'] . ' &lt;' . $arrRow['sender'] . '&gt;]</span></div>';
    }
Esempio n. 7
0
 /**
  * compile wrapper element
  */
 protected function compile()
 {
     // get included elements
     if ($this->objWrapper->getType() == ContentWrapper\Model::TYPE_START) {
         $this->Template->count = ContentWrapper\Repository::countRelatedElements($this->objWrapper);
         $cssID = $this->cssID;
         if ($cssID[0] == '') {
             $cssID[0] = sprintf($this->strIdentifier, $this->id);
             $this->cssID = $cssID;
         }
     } else {
         $start = \ContentModel::findByPk($this->bootstrap_parentId);
         if ($start !== null) {
             $start = new Attributes($start);
             $start->registerNamespaceAttributes($this->arrBootstrapAttributes);
             $start->cssID = deserialize($start->cssID, true);
             $this->Template->start = $start;
             if ($start->cssID[0] == '') {
                 $cssID = $start->cssID;
                 $cssID[0] = sprintf($this->strIdentifier, $start->id);
                 $this->cssID = $cssID;
             } else {
                 $this->cssID = $start->cssID;
             }
         }
     }
     $this->Template->identifier = $this->cssID[0];
 }
Esempio n. 8
0
 /**
  * Parse the template
  *
  * @return string
  */
 public function generate()
 {
     $objElement = \ContentModel::findByPk($this->cteAlias);
     if ($objElement === null) {
         return '';
     }
     $strClass = static::findClass($objElement->type);
     if (!class_exists($strClass)) {
         return '';
     }
     $objElement->origId = $objElement->id;
     $objElement->id = $this->id;
     $objElement->typePrefix = 'ce_';
     /** @var ContentElement $objElement */
     $objElement = new $strClass($objElement);
     $cssID = deserialize($objElement->cssID, true);
     // Override the CSS ID (see #305)
     if (!empty($this->cssID[0])) {
         $cssID[0] = $this->cssID[0];
     }
     // Merge the CSS classes (see #6011)
     if (!empty($this->cssID[1])) {
         $cssID[1] = trim($cssID[1] . ' ' . $this->cssID[1]);
     }
     $objElement->cssID = $cssID;
     return $objElement->generate();
 }
 /**
  * Parse the template
  *
  * @return string
  */
 public function generate()
 {
     $objElement = \ContentModel::findByPk($this->cteAlias);
     if ($objElement === null) {
         return '';
     }
     $strClass = static::findClass($objElement->type);
     if (!class_exists($strClass)) {
         return '';
     }
     $objElement->origId = $objElement->id;
     $objElement->id = $this->id;
     $objElement->typePrefix = 'ce_';
     /** @var \ContentElement $objElement */
     $objElement = new $strClass($objElement);
     // create new cssID array
     $cssID = array();
     // set the ID
     $cssID[0] = $this->cssID[0] ?: $objElement->cssID[0];
     // merge the classes
     $arrElementClasses = explode(' ', $this->cssID[1]);
     $arrIncludeClasses = explode(' ', $objElement->cssID[1]);
     $cssID[1] = implode(' ', array_unique(array_merge($arrIncludeClasses, $arrElementClasses)));
     // Overwrite spacing and CSS ID
     $objElement->origSpace = $objElement->space;
     $objElement->space = $this->space;
     $objElement->origCssID = $objElement->cssID;
     $objElement->cssID = $cssID;
     return $objElement->generate();
 }
Esempio n. 10
0
 /**
  * compile wrapper element
  */
 protected function compile()
 {
     if ($this->wrapper->isTypeOf(Wrapper\Helper::TYPE_START)) {
         $cssID = $this->cssID;
         if ($cssID[0] == '') {
             $cssID[0] = sprintf($this->identifier, $this->id);
             $this->cssID = $cssID;
         }
         $attributes = new Attributes();
         $attributes->addClass('carousel')->addClass('slide')->setAttribute('id', $cssID[0]);
         if ($this->bootstrap_autostart) {
             $attributes->setAttribute('data-ride', 'carousel');
         }
         if ($this->bootstrap_interval > 0) {
             $attributes->setAttribute('data-interval', $this->bootstrap_interval);
         }
         $this->Template->attributes = $attributes;
         $this->Template->count = $this->wrapper->countRelatedElements();
     } else {
         $start = \ContentModel::findByPk($this->bootstrap_parentId);
         if ($start !== null) {
             $start->cssID = deserialize($start->cssID, true);
             $this->Template->start = $start;
             if ($start->cssID[0] == '') {
                 $cssID = $start->cssID;
                 $cssID[0] = sprintf($this->identifier, $start->id);
                 $this->cssID = $cssID;
             } else {
                 $this->cssID = $start->cssID;
             }
         }
     }
     $this->Template->identifier = $this->cssID[0];
     $this->Template->wrapper = $this->wrapper;
 }
 protected function compile()
 {
     global $objPage;
     $arrElements = array();
     $objCte = \ContentModel::findPublishedByPidAndTable($objPage->id, 'tl_page');
     if ($objCte !== null) {
         $intCount = 0;
         $intLast = $objCte->count() - 1;
         while ($objCte->next()) {
             $arrCss = array();
             /** @var \ContentModel $objRow */
             $objRow = $objCte->current();
             // Add the "first" and "last" classes (see #2583)
             if ($intCount == 0 || $intCount == $intLast) {
                 if ($intCount == 0) {
                     $arrCss[] = 'first';
                 }
                 if ($intCount == $intLast) {
                     $arrCss[] = 'last';
                 }
             }
             $objRow->classes = $arrCss;
             $arrElements[] = $this->getContentElement($objRow, $this->strColumn);
             ++$intCount;
         }
     }
     $this->Template->elements = $arrElements;
     // HOOK: add custom logic
     if (isset($GLOBALS['TL_HOOKS']['compileArticle']) && is_array($GLOBALS['TL_HOOKS']['compileArticle'])) {
         foreach ($GLOBALS['TL_HOOKS']['compileArticle'] as $callback) {
             $this->import($callback[0]);
             $this->{$callback}[0]->{$callback}[1]($this->Template, $this->arrData, $this);
         }
     }
 }
Esempio n. 12
0
 public static function getPlaceholder($placeholder)
 {
     $object = new self();
     $strContent = "";
     $addStmt = "";
     $db = \Database::getInstance();
     $placeholderId = is_numeric($placeholder) ? $placeholder : 0;
     $placeholderAlias = is_string($placeholder) ? $placeholder : 0;
     if (!BE_USER_LOGGED_IN) {
         $time = time();
         $addStmt = " AND (start='' OR start<{$time}) AND (stop='' OR stop>{$time}) AND published=1";
     }
     // TODO: make a Placeholder Model!!
     $objPlaceholder = $db->prepare("SELECT * FROM tl_dps_placeholder WHERE (id=? OR alias=?)" . $addStmt)->limit(1)->execute($placeholderId, $placeholderAlias);
     if ($objPlaceholder->numRows > 0) {
         $objPlaceholder = $objPlaceholder->first();
         $id = $objPlaceholder->id;
         $objContent = \ContentModel::findPublishedByPidAndTable($id, "tl_dps_placeholder");
         if ($objContent && $objContent->count() > 0) {
             while ($objContent->next()) {
                 $strContent .= $object->replaceInsertTags($object->getContentElement($objContent->id));
             }
         }
     }
     return $strContent;
 }
 /**
  * Generate module
  */
 protected function compile()
 {
     // Get ID
     $strAlias = \Input::get('auto_item') ? \Input::get('auto_item') : \Input::get('store');
     // Find published store from ID
     if (($objStore = AnyStoresModel::findPublishedByIdOrAlias($strAlias)) !== null) {
         // load all details
         $objStore->loadDetails();
         // generate description
         $objDescription = \ContentModel::findPublishedByPidAndTable($objStore->id, $objStore->getTable());
         if ($objDescription !== null) {
             while ($objDescription->next()) {
                 $objStore->description .= \Controller::getContentElement($objDescription->current());
             }
         }
         // Get referer for back button
         $objStore->referer = $this->getReferer();
         // generate google map if template and geodata is set
         if ($this->anystores_mapTpl != '' && is_numeric($objStore->latitude) && is_numeric($objStore->longitude)) {
             $objMapTemplate = new \FrontendTemplate($this->anystores_mapTpl);
             $objMapTemplate->setData($objStore->row());
             $objStore->gMap = $objMapTemplate->parse();
         }
         // Template
         $objDetailTemplate = new \FrontendTemplate($this->anystores_detailTpl);
         $objDetailTemplate->setData($objStore->row());
         $this->Template->store = $objDetailTemplate->parse();
     } else {
         $this->_redirect404();
     }
 }
 /**
  * Generate the module
  */
 protected function compile()
 {
     global $objPage;
     $this->Template->content = '';
     $this->Template->referer = 'javascript:history.go(-1)';
     $this->Template->back = $GLOBALS['TL_LANG']['MSC']['goBack'];
     if (TL_MODE == 'FE' && BE_USER_LOGGED_IN) {
         $objNewsletter = \NewsletterModel::findByIdOrAlias(\Input::get('items'));
     } else {
         $objNewsletter = \NewsletterModel::findSentByParentAndIdOrAlias(\Input::get('items'), $this->nl_channels);
     }
     if ($objNewsletter === null) {
         // Do not index or cache the page
         $objPage->noSearch = 1;
         $objPage->cache = 0;
         // Send a 404 header
         header('HTTP/1.1 404 Not Found');
         $this->Template->content = '<p class="error">' . sprintf($GLOBALS['TL_LANG']['MSC']['invalidPage'], \Input::get('items')) . '</p>';
         return;
     }
     // Overwrite the page title (see #2853 and #4955)
     if ($objNewsletter->subject != '') {
         $objPage->pageTitle = strip_tags(strip_insert_tags($objNewsletter->subject));
     }
     // Add enclosure
     if ($objNewsletter->addFile) {
         $this->addEnclosuresToTemplate($this->Template, $objNewsletter->row(), 'files');
     }
     if (!$objNewsletter->sendText) {
         $nl2br = $objPage->outputFormat == 'xhtml' ? 'nl2br_xhtml' : 'nl2br_html5';
         $strContent = '';
         $objContentElements = \ContentModel::findPublishedByPidAndTable($objNewsletter->id, 'tl_newsletter');
         if ($objContentElements !== null) {
             if (!defined('NEWSLETTER_CONTENT_PREVIEW')) {
                 define('NEWSLETTER_CONTENT_PREVIEW', true);
             }
             foreach ($objContentElements as $objContentElement) {
                 $strContent .= $this->getContentElement($objContentElement->id);
             }
         }
         // Parse simple tokens and insert tags
         $strContent = $this->replaceInsertTags($strContent);
         $strContent = \String::parseSimpleTokens($strContent, array());
         // Encode e-mail addresses
         $strContent = \String::encodeEmail($strContent);
         $this->Template->content = $strContent;
     } else {
         $strContent = str_ireplace(' align="center"', '', $objNewsletter->content);
     }
     // Convert relative URLs
     $strContent = $this->convertRelativeUrls($strContent);
     // Parse simple tokens and insert tags
     $strContent = $this->replaceInsertTags($strContent);
     $strContent = \String::parseSimpleTokens($strContent, array());
     // Encode e-mail addresses
     $strContent = \String::encodeEmail($strContent);
     $this->Template->content = $strContent;
     $this->Template->subject = $objNewsletter->subject;
 }
 /**
  * Generate the module
  */
 protected function compile()
 {
     $this->Template->content = '';
     if (($objElement = \ContentModel::findPublishedByPidAndTable($this->User->id, 'tl_member')) !== null) {
         while ($objElement->next()) {
             $this->Template->content .= $this->getContentElement($objElement->id);
         }
     }
 }
Esempio n. 16
0
 public function beforeDelete()
 {
     $pageWidgets = PageWidget::model()->findAll(array('condition' => '`area` = :area', 'params' => array('area' => 'widget' . $this->widget->id . 'ModelArea_items'), 'with' => array('widget'), 'order' => '`order`'));
     foreach ($pageWidgets as $pageWidget) {
         $pageWidget->widget->delete();
         $pageWidget->delete();
     }
     return parent::beforeDelete();
 }
Esempio n. 17
0
 /**
  * Add product items to the indexer
  * @param array
  * @param integer
  * @param boolean
  * @return array
  */
 public function getSearchablePages($arrPages, $intRoot = 0, $blnIsSitemap = false)
 {
     $arrRoot = array();
     if ($intRoot > 0) {
         $arrRoot = $this->Database->getChildRecords($intRoot, 'tl_page');
     }
     $time = time();
     $arrProcessed = array();
     // Get all catalog categories
     $objCatalog = \ProductCatalogModel::findByProtected('');
     // Walk through each archive
     if ($objCatalog !== null) {
         while ($objCatalog->next()) {
             // Skip catalog categories without target page
             if (!$objCatalog->jumpTo) {
                 continue;
             }
             // Skip catalog categories outside the root nodes
             if (!empty($arrRoot) && !in_array($objCatalog->jumpTo, $arrRoot)) {
                 continue;
             }
             // Get the URL of the jumpTo page
             if (!isset($arrProcessed[$objCatalog->jumpTo])) {
                 $objParent = \PageModel::findWithDetails($objCatalog->jumpTo);
                 // The target page does not exist
                 if ($objParent === null) {
                     continue;
                 }
                 // The target page has not been published (see #5520)
                 if (!$objParent->published || $objParent->start != '' && $objParent->start > $time || $objParent->stop != '' && $objParent->stop < $time) {
                     continue;
                 }
                 // The target page is exempt from the sitemap (see #6418)
                 if ($blnIsSitemap && $objParent->sitemap == 'map_never') {
                     continue;
                 }
                 // Set the domain (see #6421)
                 $domain = ($objParent->rootUseSSL ? 'https://' : 'http://') . ($objParent->domain ?: \Environment::get('host')) . TL_PATH . '/';
                 // Generate the URL
                 $arrProcessed[$objCatalog->jumpTo] = $domain . $this->generateFrontendUrl($objParent->row(), \Config::get('useAutoItem') && !\Config::get('disableAlias') ? '/%s' : '/items/%s', $objParent->language);
             }
             $strUrl = $arrProcessed[$objCatalog->jumpTo];
             // Get the items
             $objProduct = \ProductModel::findPublishedByPid($objCatalog->id);
             if ($objProduct !== null) {
                 while ($objProduct->next()) {
                     $objElement = \ContentModel::findPublishedByPidAndTable($objProduct->id, 'tl_product');
                     if ($objElement !== null) {
                         $arrPages[] = $this->getLink($objProduct, $strUrl);
                     }
                 }
             }
         }
     }
     return $arrPages;
 }
 public function update()
 {
     $content = new ContentModel();
     $id = $_POST['id'];
     if ($id != '') {
         $data['id'] = $id;
         $data['title'] = $_POST['title'];
         $data['content'] = $_POST['content'];
         if ($content->save($data)) {
             $this->assign("jumpUrl", "__URL__/index");
             $this->success("更新数据成功!");
         } else {
             $this->assign("jumpUrl", "__URL__/index");
             $this->success("更新数据失败!");
         }
     } else {
         echo "保存数据失败!";
     }
 }
Esempio n. 19
0
 public function modifyPalette(DataContainer $dc)
 {
     $objElement = \ContentModel::findByPk($dc->id);
     if ($objElement === null || $objElement->type != 'linkteaser' || $objElement->source != 'modal') {
         return false;
     }
     $GLOBALS['TL_DCA']['tl_content']['fields']['jumpTo']['label'] =& $GLOBALS['TL_LANG']['tl_content']['modalJumpTo'];
     $GLOBALS['TL_DCA']['tl_content']['fields']['jumpTo']['eval']['mandatory'] = false;
     $GLOBALS['TL_DCA']['tl_content']['fields']['jumpTo']['eval']['tl_class'] = 'clr w50';
 }
Esempio n. 20
0
 public function index()
 {
     //编号,也就是下载第几个链接,有的是多文件下载用的!
     $k = I('get.k', 0, 'intval');
     //字段名称
     $f = I('get.f', '');
     if (empty($this->id) || empty($this->catid) || empty($f)) {
         $this->error("参数有误!");
     }
     //模型ID
     $modelid = getCategory($this->catid, 'modelid');
     $Model_field = F("Model_field_" . $modelid);
     //判断字段类型
     if (!in_array($Model_field[$f]['formtype'], array('downfiles', 'downfile'))) {
         $this->error('下载地址错误!');
     }
     $this->db = ContentModel::getInstance($modelid);
     $data = $this->db->relation(true)->where(array("id" => $this->id, 'status' => 99))->find();
     if (empty($data)) {
         $this->error("该信息不存在!");
     }
     $this->db->dataMerger($data);
     if (!empty($data)) {
         //取得下载字段信息
         $downfiles = $data[$f];
         $dowUnserialize = unserialize($downfiles);
         if ($dowUnserialize) {
             $info = $dowUnserialize[$k];
             if (empty($info)) {
                 $this->error("该下载地址已经失效!");
             }
         } else {
             $info = array();
             $info['filename'] = basename($downfiles);
             $info['point'] = 0;
             $info['groupid'] = 0;
         }
         //当前客户端标识
         $aut = md5($this->userid . $this->groupid . substr($_SERVER['HTTP_USER_AGENT'], 0, 254));
         //加密
         //格式:aut|栏目ID|信息id|下载编号|字段
         $key = authcode(implode('|', array($aut, $this->catid, $this->id, $k, $f)), '', '', 3600);
         $this->assign("info", $data);
         $this->assign("fileurl", U("Download/d", array('key' => urlencode($key))));
         $this->assign("filename", $info['filename']);
         $this->assign("point", $info['point']);
         $this->assign("groupid", $info['groupid']);
         $this->assign("Member_group", F("Member_group"));
         $this->assign("SEO", seo($this->catid, urldecode($info['filename']), '', ''));
         $this->display("Public:download");
     } else {
         $this->error("该信息不存在!");
     }
 }
 protected function createContentElements(&$objItem)
 {
     if ($objItem->tl_content) {
         // need to wrap <p> around text for contao
         $tidyConfig = array('enclose-text' => true, 'drop-font-tags' => true, 'drop-proprietary-attributes' => true, 'quote-ampersand' => true, 'clean' => false, 'wrap-attributes' => false, 'wrap' => 500);
         $bodyText = '<!DOCTYPE html><head><title></title></head><body>' . $objItem->tl_content . '</body></html>';
         //			$bodyText = $this->convert_external_link_tags($bodyText);
         //			$bodyText = $this->convert_internal_link_tags($bodyText);
         $bodyText = $this->nl2p($bodyText);
         $tidy = new \tidy();
         $tidy->parseString($bodyText, $tidyConfig, $GLOBALS['TL_CONFIG']['dbCharset']);
         $body = $tidy->body();
         $objContent = new \ContentModel();
         $objContent->text = urldecode($objContent->text);
         // decode, otherwise link and email regex wont work
         $objContent->text = trim(str_replace(array('<body>', '</body>'), '', $body));
         $objContent->text = preg_replace("/<img[^>]+\\>/i", "", $objContent->text);
         // strip images
         // remove inline styles
         $objContent->text = preg_replace('#(<[a-z ]*)(style=("|\')(.*?)("|\'))([a-z ]*>)#', '\\1\\6', $objContent->text);
         // remove white space from empty tags
         $objContent->text = preg_replace('#(<[a-z]*)(\\s+)>#', '$1>', $objContent->text);
         // create links from text
         $objContent->text = preg_replace('!(\\s|^)((https?://|www\\.)+[a-z0-9_./?=&-]+)!i', ' <a href="http://$2" target="_blank">$2</a>', $objContent->text);
         // replace <b> by <strong>
         $objContent->text = preg_replace('!<b(.*?)>(.*?)</b>!i', '<strong>$2</strong>', $objContent->text);
         // replace plain email text with inserttags
         $objContent->text = preg_replace('/([A-Z0-9._%+-]+)@([A-Z0-9.-]+)\\.([A-Z]{2,4})(\\((.+?)\\))?(?![^<]*>)(?![^>]*<)/i', "{{email::\$1@\$2.\$3}}", $objContent->text);
         // replace email links with inserttags
         $objContent->text = preg_replace('/<a.*href=[\'|"]mailto:([A-Z0-9._%+-]+)@([A-Z0-9.-]+)\\.([A-Z]{2,4})(\\((.+?)\\))?[\'|"].*>(.*)<\\/a>/i', "{{email::\$1@\$2.\$3}}", $objContent->text);
         // strip not allowed tags
         $objContent->text = strip_tags($objContent->text, \Config::get('allowedTags'));
         $objContent->text = $this->stripAttributes($objContent->text, array('style', 'class', 'id'));
         $objContent->ptable = $this->dbTargetTable;
         $objContent->pid = $objItem->id;
         $objContent->sorting = 16;
         $objContent->tstamp = time();
         $objContent->type = 'text';
         $objContent->save();
     }
 }
Esempio n. 22
0
 /**
  * 根据content_archives_id获取文档
  * @param mixed $content_archives_id    文档编号
  * @return string $content_archives     文档
  */
 public static function get_archive_by_id($content_archives_id, $allow_cache = false)
 {
     $content_archives_name = '';
     if (!$content_archives_id) {
         return '';
     }
     //有开启缓存功能,则从缓存中取数据, 如果有数据,则直接返回结果
     if ($allow_cache && Yii::app()->cache) {
         $_cache_key = 'content.archive.row.' . $content_archives_id;
         $_r = Yii::app()->cache->get($_cache_key);
         if ($_r && is_array($_r)) {
             return $_r;
         }
     }
     $cmd = Yii::app()->db->createCommand();
     $cmd->select('a.content_archives_id, ac.content_model_id, m.content_model_name, ac.class_id, ac.class_name, a.content_archives_subject, a.content_archives_color, a.content_archives_short_subject, a.content_archives_flag, a.content_archives_jump_url, a.content_archives_source, a.content_archives_author, a.content_archives_thumb, a.content_archives_keywords, a.content_archives_summary, a.content_archives_status, a.content_archives_rank, a.content_archives_pubtime, a.content_archives_lasttime, a.content_archives_dateline')->from('{{content_archives}} a')->join('{{content_archives_classes_relating}} acr', 'acr.content_archives_id=a.content_archives_id')->join('{{content_archives_classes}} ac', 'ac.class_id=acr.class_id')->join('{{content_model}} m', 'm.content_model_id=ac.content_model_id')->where('a.content_archives_id=:content_archives_id', array('content_archives_id' => $content_archives_id));
     $_r = $cmd->queryRow();
     if ($_r) {
         //附加表结构
         $_r['content_model_colums'] = ContentModel::get_model_table_by_id($_r['content_model_id']);
         //附加表数据
         $content_model_identify = ContentModel::get_model_identify_by_id($_r['content_model_id']);
         $_sql = "SELECT * FROM {{content_addons{$content_model_identify}}} WHERE content_archives_id=:content_archives_id LIMIT 0, 1";
         $cmd = Yii::app()->db->createCommand($_sql);
         $cmd->bindValue(':content_archives_id', $content_archives_id);
         $_a_r = $cmd->queryRow();
         if (is_array($_a_r)) {
             //
             foreach ($_r['content_model_colums'] as $_k => $_v) {
                 if ($_v['content_model_field_type'] == ContentModelField::DATA_TYPE_CHECKBOX) {
                     $_a_r[$_v['content_model_field_identify']] = unserialize($_a_r[$_v['content_model_field_identify']]);
                 }
             }
             $_r = array_merge($_r, $_a_r);
         }
         unset($_a_r);
         //自定义属性
         $_r['content_archives_flag'] = explode(',', $_r['content_archives_flag']);
         //文档栏目
         $_sql = "SELECT c.*\n\t\t\t\t\tFROM {{content_archives_classes_relating}} cr\n\t\t\t\t\tINNER JOIN {{content_archives_classes}} c ON c.class_id = cr.class_id \n\t\t\t\t\tWHERE cr.content_archives_id=:content_archives_id";
         $_r['content_archives_classes'] = Yii::app()->db->createCommand($_sql)->queryAll(true, array(':content_archives_id' => $content_archives_id));
         //文档标签
         $_sql = "SELECT tags_id, tags_name\n\t\t\t\t\tFROM {{content_archives_tags}}\n\t\t\t\t\tWHERE content_archives_id=:content_archives_id\n\t\t\t\t\tORDER BY tags_id ASC";
         $_r['content_archives_tags'] = Yii::app()->db->createCommand($_sql)->queryAll(true, array(':content_archives_id' => $content_archives_id));
     }
     //有开启缓存,则把结果添加到缓存中
     if ($allow_cache && Yii::app()->cache) {
         $_cache_time_out = Setting::getSettingCache('GOODS_ROW_TIME_OUT');
         Yii::app()->cache->set($_cache_key, $_r, $_cache_time_out);
         unset($_cache_time_out, $_cache_key);
     }
     return $_r ? $_r : array();
 }
Esempio n. 23
0
 /**
  * Modify the current datacontainer palette
  *
  * @param \DataContainer $dc
  *
  * @return bool
  */
 public function modifyPalette(\DataContainer $dc)
 {
     $id = strlen(\Input::get('id')) ? \Input::get('id') : CURRENT_ID;
     $objModel = \ContentModel::findByPk($id);
     if ($objModel === null || $objModel->type != 'linkteaser') {
         return false;
     }
     $dca =& $GLOBALS['TL_DCA']['tl_content'];
     // make text non mandatory
     $dca['fields']['text']['eval']['mandatory'] = false;
     $dca['fields']['target']['load_callback'][] = array(__CLASS__, 'setTargetFlags');
 }
 /**
  * Invoke the rendering.
  *
  * @param array $row The child as array.
  *
  * @return mixed|string
  */
 public function __invoke($row)
 {
     $buffer = call_user_func($this->callback, $row);
     if ($row['ptable'] === 'tl_content_node') {
         $parent = \ContentModel::findByPk($row['pid']);
         if ($this->registry->hasNodeType($parent->type)) {
             $node = $this->registry->getNode($parent->type);
             return $node->generateChildInBackendView($row, $buffer);
         }
     }
     return $buffer;
 }
 private function showComment()
 {
     if (isset($_GET['cid'])) {
         parent::__construct($this->_tpl, new CommentModel());
         $this->_model->cid = $_GET['cid'];
         $_content = new ContentModel();
         $_content->id = $_GET['cid'];
         if (!$_content->getOneContent()) {
             Tool::alertBack('comment not existing');
         }
         parent::page($this->_model->getCommentTotal());
         $_object = $this->_model->getAllComment();
         $_object2 = $this->_model->getHotThreeComment();
         $_object3 = $_content->getHotTwentyComment();
         $this->setObject($_object);
         $this->setObject($_object2);
         $this->_tpl->assign('titlec', $_content->getOneContent()->title);
         $this->_tpl->assign('info', $_content->getOneContent()->info);
         $this->_tpl->assign('id', $_content->getOneContent()->id);
         $this->_tpl->assign('cid', $this->_model->cid);
         $this->_tpl->assign('AllComment', $_object);
         $this->_tpl->assign('HotThreeComment', $_object2);
         $this->_tpl->assign('HotTwentyComment', $_object3);
     } else {
         Tool::alertBack('illegal act');
     }
 }
 /**
  * Redirect to the content page when trying to access the content node.
  *
  * This fixes the edit links on the header.
  *
  * @return void
  */
 public function redirect()
 {
     if ($this->input->get('table') === 'tl_content_node') {
         $model = \ContentModel::findByPk($this->input->get('id'));
         if (!$model) {
             \Controller::log(sprintf('Content node "%s" not found', $this->input->get('id')), __METHOD__, TL_ERROR);
             \Controller::redirect('contao/main.php?act=error');
         }
         $nodes = $model->ptable === 'tl_content_node' ? '1' : '';
         $url = \Backend::addToUrl('table=tl_content&amp;nodes=' . $nodes);
         \Controller::redirect($url);
     }
 }
 /**
  * 审核文章
  */
 public function audit()
 {
     if ($aids = Q('aid')) {
         $ContentModel = ContentModel::getInstance($this->mid);
         foreach ($aids as $aid) {
             $data = array('aid' => $aid, 'content_status' => 1);
             $ContentModel->save($data);
         }
         $this->success('操作成功');
     } else {
         $this->error('参数错误');
     }
 }
Esempio n. 28
0
 public function del($aid)
 {
     $ContentModel = ContentModel::getInstance($this->mid);
     if ($ContentModel->del($aid)) {
         //删除文章tag属性
         M('content_tag')->where(array('cid' => $this->cid))->del();
         //生成栏目静态
         $this->createCategoryHtml($this->cid);
         Hook::listen('content_del');
         return true;
     } else {
         $this->error = '删除文章失败';
     }
 }
Esempio n. 29
0
 /**
  * added in 4.9.0
  */
 public static function renameContentElementsOrFrontendModules()
 {
     // Rename CTE's
     $objContent = \ContentModel::findByType('gallery_creator');
     if ($objContent !== null) {
         $objContent->type = 'gallery_creator_ce';
         $objContent->save();
     }
     // Rename FMD's
     $objModule = \ModuleModel::findByType('gallery_creator');
     if ($objModule !== null) {
         $objModule->type = 'gallery_creator_fmd';
         $objModule->save();
     }
 }
Esempio n. 30
0
 public function getContentSliderCarousels(DataContainer $dc)
 {
     $arrOptions = array();
     $objSlider = \ContentModel::findBy('type', 'slick-content-start');
     if ($objSlider === null) {
         return $arrOptions;
     }
     while ($objSlider->next()) {
         $objArticle = \ArticleModel::findByPk($objSlider->pid);
         if ($objArticle === null) {
             continue;
         }
         $arrOptions[$objSlider->id] = sprintf($GLOBALS['TL_LANG']['tl_content']['contentSliderCarouselSelectOption'], $objArticle->title, $objArticle->id, $objSlider->id);
     }
     return $arrOptions;
 }