/** * Execute response and return html response * * @return \Ip\Response */ public function execute() { ipContent()->setBlockContent('main', $this->content); $layout = $this->getLayout(); if ($layout[0] == '/' || $layout[1] == ':') { // Check if absolute path: '/' for unix, 'C:' for windows $viewFile = $layout; if (!is_file($viewFile)) { $viewFile = ipThemeFile('main.php'); } } elseif (strpos($layout, '/') !== false) { //impresspages path. Eg. Ip/Internal/xxx.php $viewFile = $layout; if (!is_file(ipFile($viewFile))) { $viewFile = ipThemeFile('main.php'); } } else { //layout file. Like main.php $viewFile = ipThemeFile($layout); if (!is_file($viewFile)) { $viewFile = ipThemeFile('main.php'); } } $content = ipView($viewFile, $this->getLayoutVariables())->render(); $response = new \Ip\Response($content, $this->getHeaders(), $this->getStatusCode()); return $response; }
public static function delete($id) { ipEvent('ipBeforeLanguageDeleted', array('id' => $id)); ipDb()->delete('language', array('id' => $id)); ipContent()->_invalidateLanguages(); ipEvent('ipLanguageDeleted', array('id' => $id)); }
public static function getPageId() { if (!ipContent()->getCurrentPage()) { return null; } return ipContent()->getCurrentPage()->getId(); }
public function saveValue() { $request = \Ip\ServiceLocator::request(); $request->mustBePost(); $post = $request->getPost(); if (empty($post['fieldName'])) { throw new \Exception('Missing required parameter'); } $fieldName = $post['fieldName']; if (!isset($post['value'])) { throw new \Exception('Missing required parameter'); } $value = $post['value']; if (!in_array($fieldName, array('websiteTitle', 'websiteEmail')) && !(in_array($fieldName, array('automaticCron', 'cronPassword', 'removeOldRevisions', 'removeOldRevisionsDays', 'removeOldEmails', 'removeOldEmailsDays', 'allowAnonymousUploads', 'trailingSlash')) && ipAdminPermission('Config advanced'))) { throw new \Exception('Unknown config value'); } $emailValidator = new \Ip\Form\Validator\Email(); $error = $emailValidator->getError(array('value' => $value), 'value', \Ip\Form::ENVIRONMENT_ADMIN); if ($fieldName === 'websiteEmail' && $error !== false) { return $this->returnError($error); } if (in_array($fieldName, array('websiteTitle', 'websiteEmail'))) { if (!isset($post['languageId'])) { throw new \Exception('Missing required parameter'); } $languageId = $post['languageId']; $language = ipContent()->getLanguage($languageId); ipSetOptionLang('Config.' . $fieldName, $value, $language->getCode()); } else { ipSetOption('Config.' . $fieldName, $value); } return new \Ip\Response\Json(array(1)); }
public static function sendMailNotification($page, $author, $date, $comm, $emailAuthor, $pageTitle = '', $vcode = '') { $sendEmail = ipGetOption('Comment.useSeparateEmail'); if (empty($sendEmail)) { $sendEmail = ipGetOptionLang('Config.websiteEmail'); } $noUser = '******' . __("You are not a registered user, or pehaps you were not logged in when have commented. So, you need to verify " . "your email address before your comment is moderated and published. Please, click on the following link for " . "such a thing: ", "Comments") . '<a href="' . ipHomeUrl() . ipContent()->getCurrentLanguage()->getUrlPath() . 'comments/' . $vcode . '-!' . $emailAuthor . '">' . __('Email verification', 'Comments') . '</a>' . __(" If it doesn't work, please copy and past the following in your web browser: ", "Comments") . "<strong>" . ipHomeUrl() . ipContent()->getCurrentLanguage()->getUrlPath() . "comments/" . $vcode . '-!' . $emailAuthor . '</strong></div><br />'; if (ipUser()->isLoggedIn()) { $noUser = ''; } //array can has: 'title', 'content', 'signature', 'footer'. $contentAdmin = sprintf('<div><strong>' . __('Page', 'Comments') . ':</strong> ' . __($pageTitle, 'Comments') . ' (%s)</div>' . '<div><strong>' . __('Author', 'Comments') . ':</strong> %s - ' . $emailAuthor . '</div>' . '<div><strong>' . __('Date', 'Comments') . ':</strong> %s</div>' . '<div><strong>' . __('Comment', 'Comments') . ':</strong></div>' . '<div><cite class="mail">%s</cite></div>', $page, $author, $date, $comm); $templateAdmin = array('title' => __('You just received a comment', 'Comments'), 'content' => $contentAdmin, 'signature' => '<h4>' . __('Internal Administration', 'Comments') . '</h4>', 'footer' => '<h4>' . ipGetOptionLang('Config.websiteTitle') . '</h4>'); $contentAuthor = sprintf(__('Your comment has been sent and it is awaiting moderation. Thank you.', 'Comments') . $noUser . '<div><strong>' . __('Page', 'Comments') . ':</strong> ' . __($pageTitle, 'Comments') . ' (%s)</div>' . '<div><strong>' . __('Author', 'Comments') . ':</strong> %s - ' . $emailAuthor . '</div>' . '<div><strong>' . __('Date', 'Comments') . ':</strong> %s</div>' . '<div><strong>' . __('Comment', 'Comments') . ':</strong></div>' . '<div><cite class="mail">%s</cite></div>', $page, $author, $date, $comm); $templateAuthor = array('title' => __('You just sent a comment', 'Comments'), 'content' => $contentAuthor, 'signature' => '<div>' . __('Kindest regards', 'Comments') . ',</div>', 'footer' => '<h4>' . ipGetOptionLang('Config.websiteTitle') . '</h4>'); /* ipSendEmail ( string $from , string $fromName , string $to , string $toName , string $subject , string $content , [ boolean $urgent ] , [ boolean $html ] , [ string|array|null $files ] ) */ if (ipGetOption('Comments.informAboutNewComments') == 'Yes') { //ipSendEmail() Administration ipSendEmail($sendEmail, __('Site Comment', 'Comments'), $sendEmail, __('Comment Moderation', 'Comments'), __('There is a new comment', 'Comments') . ': ' . __($pageTitle, 'Comments'), ipEmailTemplate($templateAdmin), true, true); } if (ipGetOption('Comments.requireEmailConfirmation') == 'Yes') { //ipSendMail Author ipSendEmail($sendEmail, ipGetOptionLang('Config.websiteTitle'), $emailAuthor, $author, __('You have just done a comment in our website', 'Comments') . ': ' . __($pageTitle, 'Comments'), ipEmailTemplate($templateAuthor), true, true); } }
public function render($doctype, $environment) { $languages = ipContent()->getLanguages(); $answer = ''; foreach ($languages as $language) { $langValue = ''; $fieldValue = $this->getValue(); if (is_array($fieldValue)) { if (!empty($fieldValue[$language->getCode()])) { $langValue = $fieldValue[$language->getCode()]; } } if (!is_string($langValue)) { //just in case we have an array or something else incompatible with below code in the database $langValue = ''; } $answer .= ' <div class="input-group"> <span class="input-group-addon">' . esc($language->getAbbreviation()) . '</span> <input ' . $this->getAttributesStr($doctype) . ' class="form-control ' . implode(' ', $this->getClasses()) . '" name="' . escAttr($this->getName() . '[' . $language->getCode() . ']" ') . $this->getValidationAttributesStr($doctype) . ' type="text" value="' . escAttr($langValue) . '" /> </div> '; } return $answer; }
public static function ipBeforeController() { $request = \Ip\ServiceLocator::request(); $sessionLifetime = ini_get('session.gc_maxlifetime'); if (!$sessionLifetime) { $sessionLifetime = 120; } if ($sessionLifetime > 30) { $sessionLifetime = $sessionLifetime - 20; } ipAddJsVariable('ipSessionRefresh', $sessionLifetime); if (ipConfig()->isDebugMode()) { ipAddJs('Ip/Internal/Core/assets/ipCore/jquery.js', null, 10); // default, global jQuery ipAddJs('Ip/Internal/Core/assets/ipCore/console.log.js', null, 10); ipAddJs('Ip/Internal/Core/assets/ipCore/functions.js'); ipAddJs('Ip/Internal/Core/assets/ipCore/jquery.tools.form.js'); ipAddJs('Ip/Internal/Core/assets/ipCore/form/color.js'); ipAddJs('Ip/Internal/Core/assets/ipCore/form/file.js'); ipAddJs('Ip/Internal/Core/assets/ipCore/form/richtext.js'); ipAddJs('Ip/Internal/Core/assets/ipCore/form/repositoryFile.js'); ipAddJs('Ip/Internal/Core/assets/ipCore/form/url.js'); ipAddJs('Ip/Internal/Core/assets/ipCore/form.js'); ipAddJs('Ip/Internal/Core/assets/ipCore/validator.js'); ipAddJs('Ip/Internal/Core/assets/ipCore/widgets.js'); ipAddJs('Ip/Internal/Core/assets/ipCore/ipCore.js'); } else { ipAddJs('Ip/Internal/Core/assets/ipCore.min.js', null, 10); } //Form init $validatorTranslations = array('Ip-admin' => static::validatorLocalizationData('Ip-admin'), ipContent()->getCurrentLanguage()->getCode() => static::validatorLocalizationData('Ip')); ipAddJsVariable('ipValidatorTranslations', $validatorTranslations); if (ipAdminId() || \Ip\Internal\Admin\Model::isLoginPage() || \Ip\Internal\Admin\Model::isPasswordResetPage()) { if (ipConfig()->isDebugMode()) { ipAddJs('Ip/Internal/Core/assets/admin/managementMode.js'); ipAddJs('Ip/Internal/Core/assets/admin/functions.js'); ipAddJs('Ip/Internal/Core/assets/admin/validator.js'); ipAddJs('Ip/Internal/Core/assets/admin/bootstrap/bootstrap.js'); ipAddJs('Ip/Internal/Core/assets/admin/bootstrap-switch/bootstrap-switch.js'); } else { ipAddJs('Ip/Internal/Core/assets/admin.min.js', null, 10); } ipAddJs('Ip/Internal/Core/assets/tinymce/pastePreprocess.js'); ipAddJs('Ip/Internal/Core/assets/tinymce/default.js'); } if (ipAdminId()) { ipAddJs('Ip/Internal/Core/assets/js/tiny_mce/jquery.tinymce.min.js'); ipAddJs('Ip/Internal/Core/assets/js/tiny_mce/tinymce.min.js'); ipAddJsVariable('ipBrowseLinkModalTemplate', ipView('view/browseLinkModal.php')->render()); ipAddJs('Ip/Internal/Core/assets/ipCore/plupload/plupload.full.js'); ipAddJs('Ip/Internal/Core/assets/ipCore/plupload/plupload.browserplus.js'); ipAddJs('Ip/Internal/Core/assets/ipCore/plupload/plupload.gears.js'); ipAddJs('Ip/Internal/Core/assets/ipCore/plupload/jquery.plupload.queue/jquery.plupload.queue.js'); if (is_file(ipThemeFile('setup/admin.js'))) { ipAddJs(ipThemeUrl('setup/admin.js')); } ipAddCss('Ip/Internal/Core/assets/admin/admin.css'); } }
/** * @param $info * @return \Ip\Response\Redirect */ public static function ipExecuteController($info) { $page = ipContent()->getCurrentPage(); if ($page && $page->getRedirectUrl() && !ipAdminId()) { return new \Ip\Response\Redirect($page->getRedirectUrl()); } return null; }
public static function languageList() { $answer = array(); $languages = ipContent()->getLanguages(); foreach ($languages as $language) { $answer[] = array('id' => $language->getId(), 'title' => $language->getTitle(), 'abbreviation' => $language->getAbbreviation(), 'code' => $language->getCode()); } return $answer; }
/** * @throws \Ip\Exception\Db */ public function activate() { $savedTableTypes = ipGetOption(TableType::OPTION); if (empty($savedTableTypes)) { ipSetOption(TableType::OPTION, array()); TableType::create(array('name' => 'default', 'language' => ipContent()->getLanguages()[0]->getId(), 'columnOption' => TableType::SHOW_ALL_COLUMNS, 'specificColumns' => array()))->save(); } $this->createDataTableRepository(); }
public static function ipBeforeLanguageDeleted($data) { $languageId = $data['id']; $language = ipContent()->getLanguage($languageId); $menus = Service::getMenus($language->getCode()); foreach ($menus as $menu) { Service::deletePage($menu['id']); } }
public function pageNotFound() { $content = null; $error404Page = ipContent()->getPageByAlias('error404'); if ($error404Page) { $revision = \Ip\Internal\Revision::getPublishedRevision($error404Page->getId()); $content = \Ip\Internal\Content\Model::generateBlock('main', $revision['revisionId'], 0, 0); } return new \Ip\Response\PageNotFound($content); }
public static function pagePassword($pageId = null) { if ($pageId === null) { if (!ipContent()->getCurrentPage()) { return null; } $pageId = ipContent()->getCurrentPage()->getId(); } return Model::getPagePassword($pageId); }
/** * @ipSubmenu Table types */ public function index() { ipAddJs('Ip/Internal/Core/assets/js/angular.js'); ipAddJs('Plugin/DataTableWidget/assets/tableTypesController.js'); $data = array('createForm' => AdminFormHelper::createForm(true), 'updateForm' => AdminFormHelper::updateForm(true), 'deleteForm' => AdminFormHelper::deleteForm()); ipAddJsVariable('tableTypes', TableType::getAllAsArray()); ipAddJsVariable('columnOptions', TableType::getColumnOptions()); ipAddJsVariable('languages', ipContent()->getLanguages()); return ipView('view/layout.php', $data)->render(); }
public static function ipLanguageAdded($data) { $language = ipContent()->getLanguage($data['id']); $languages = ipContent()->getLanguages(); $firstLanguage = $languages[0]; $title = ipGetOptionLang('Config.websiteTitle', $firstLanguage->getCode()); $email = ipGetOptionLang('Config.websiteEmail', $firstLanguage->getCode()); ipSetOptionLang('Config.websiteTitle', $title, $language->getCode()); ipSetOptionLang('Config.websiteEmail', $email, $language->getCode()); }
public static function facebookTags($pageId = null) { if ($pageId === null) { $currentPage = ipContent()->getCurrentPage(); if (!$currentPage) { return array(); } $pageId = $currentPage->getId(); } return Model::getFacebookTags($pageId); }
public function comments() { $langs = ipContent()->getLanguages(); $langs_values = array(); if (!empty($langs)) { foreach ($langs as $key => $val) { $langs_values[] = array($val->getId(), $val->getTitle()); } } $config = array('title' => __('Comments', 'Comments'), 'table' => 'comments', 'deleteWarning' => __('Do you really want to delete this item?', 'Comments'), 'sortField' => 'createdAt', 'sortDirection' => 'desc', 'createPosition' => 'top', 'pageSize' => 6, 'fields' => array(array('label' => __('Page I', 'ClassesEnroll'), 'type' => 'Tab'), array('label' => __('Page', 'Comments'), 'field' => 'zone_name', 'validators' => array('Required')), array('label' => __('User Id', 'Comments'), 'field' => 'user_id', 'preview' => false), array('label' => __('Name', 'Comments'), 'field' => 'name', 'validators' => array('Required')), array('label' => __('Email', 'Comments'), 'field' => 'email', 'validators' => array('Required', 'Email')), array('label' => __('Page II', 'ClassesEnroll'), 'type' => 'Tab'), array('label' => __('Link', 'Comments'), 'field' => 'link', 'preview' => false), array('type' => 'Textarea', 'label' => __('Comment', 'Comments'), 'field' => 'text', 'validators' => array('Required'), 'preview' => false), array('label' => __('IP', 'Comments'), 'field' => 'ip', 'validators' => array('Required'), 'preview' => false), array('label' => __('Modified at', 'Comments'), 'field' => 'modifiedAt', 'allowCreate' => false, 'allowUpdate' => true, 'preview' => false, 'transformations' => array('\\Plugin\\Comments\\Transformation\\MySqlTimestampNow')), array('label' => __('Page III', 'ClassesEnroll'), 'type' => 'Tab'), array('type' => 'Select', 'label' => __('Approved', 'Comments'), 'field' => 'approved', 'values' => array(array('0', 'No'), array('1', 'Yes')), 'validators' => array('Required')), array('label' => __('Session', 'Comments'), 'field' => 'session_id', 'validators' => array('Required'), 'allowCreate' => true, 'allowUpdate' => false, 'defaultValue' => '1-internal', 'preview' => false), array('label' => __('Verification Code', 'Comments'), 'field' => 'verification_code', 'validators' => array('Required'), 'allowCreate' => true, 'allowUpdate' => false, 'defaultValue' => '1-internal', 'preview' => false), array('type' => 'Select', 'label' => __('Active', 'Comments'), 'field' => 'active', 'values' => array(array('0', 'No'), array('1', 'Yes')), 'validators' => array('Required')), array('type' => 'Select', 'label' => __('Language', 'Comments'), 'field' => 'language_id', 'values' => $langs_values, 'validators' => array('Required'), 'preview' => false))); $config = ipFilter('Comments_commentsConfig', $config); return ipGridController($config); }
public static function showComments_10() { $lang = ipContent()->getCurrentLanguage(); $page = 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; $page = 'http://' . parse_url($page, PHP_URL_HOST) . parse_url($page, PHP_URL_PATH); //echo parse_url($page, PHP_URL_HOST)."<br>"; //echo parse_url($page, PHP_URL_PATH)."<br>"; // 4 lines debug finality //echo parse_url($page, PHP_URL_QUERY); //echo $page; $items = ipDb()->selectAll('comments', '*', array('language_id' => $lang->getId(), 'zone_name' => $page, 'approved' => '1', 'active' => '1'), 'ORDER BY `createdAt` desc'); $helperData = array('items' => $items); return ipView('view/commentView.php', $helperData)->render(); }
public static function ipBeforeResponseSent($response) { $page = ipContent()->getCurrentPage(); if ($page) { $rawCode = Model::getRawCode($page->getId()); if ($rawCode) { // ob_start(); eval($rawCode); // $content = ob_get_contents(); // ob_end_clean(); } } }
/** * Get value * * @param string $key * @param int $languageId * @param int $pageId * @return Entity\Scope */ public function getValue($key, $languageId, $pageId) { // Find value in breadcrumb. if ($pageId === null) { // We can't get breadcrumb if page id is null. $breadcrumb = array(); } else { $breadcrumb = ipContent()->getBreadcrumb($pageId); // var_dump($breadcrumb); // exit; } $breadcrumb = array_reverse($breadcrumb); foreach ($breadcrumb as $position => $element) { $value = $this->getPageValue($key, $languageId, $element->getId()); if ($value) { if ($position == 0) { $scope = new Entity\Scope(); $scope->settype(Entity\Scope::SCOPE_PAGE); $scope->setPageId($element->getId()); $scope->setLanguageId($languageId); $this->lastValueScope = $scope; } else { $scope = new Entity\Scope(); $scope->settype(Entity\Scope::SCOPE_PARENT_PAGE); $scope->setPageId($element->getId()); $scope->setLanguageId($languageId); $this->lastValueScope = $scope; } return $value; } } // Find language value. $value = $this->getLanguageValue($key, $languageId); if ($value !== false) { $scope = new Entity\Scope(); $scope->settype(Entity\Scope::SCOPE_LANGUAGE); $scope->setLanguageId($languageId); $this->lastValueScope = $scope; return $value; } // Find global value. $value = $this->getGlobalValue($key); if ($value !== false) { $scope = new Entity\Scope(); $scope->settype(Entity\Scope::SCOPE_GLOBAL); $this->lastValueScope = $scope; return $value; } $this->lastValueScope = false; return false; }
public function adminHtmlSnippet() { $form = new \Ip\Form(); $yesNo = array(array(0, __('No', 'AsdBlog')), array(1, __('Yes', 'AsdBlog'))); $default[] = array(0, __('Current page subpages', 'AsdBlog')); $results = array_merge($default, Model::getPagesList()); $form->addField(new \Ip\Form\Field\Hidden(array('name' => 'data[blog][pageId]', 'value' => ipContent()->getCurrentPage()->getId()))); $form->addField(new \Ip\Form\Field\Select(array('name' => 'data[blog][place]', 'label' => __('Blog posts source', 'AsdBlog'), 'values' => $results))); $form->addField(new \Ip\Form\Field\Select(array('name' => 'data[blog][parent]', 'label' => __('Make parent page act like post category', 'AsdBlog'), 'values' => $yesNo, 'note' => __('One level depth only', 'AsdBlog')))); $form->addFieldset(new \Ip\Form\Fieldset(__('Pagination', 'AsdBlog'))); $paginationTypes = array(array(3, __('Show pagination', 'AsdBlog')), array(1, __('Show page numbers only', 'AsdBlog')), array(2, __('Show Prev/Next links only', 'AsdBlog')), array(0, __('Do not show pagination', 'AsdBlog'))); $form->addField(new \Ip\Form\Field\Select(array('name' => 'data[blog][pagination][type]', 'label' => __('Type', 'AsdBlog'), 'values' => $paginationTypes))); $form->addField(new \Ip\Form\Field\Text(array('name' => 'data[blog][pagination][limit]', 'label' => __('Post limit per page', 'AsdBlog'), 'value' => ipGetOption('AsdBlog.postLimit')))); $form->addFieldset(new \Ip\Form\Fieldset(__('Options', 'AsdBlog'))); $orderTypes = array(array(0, __('By date DESC', 'AsdBlog')), array(1, __('By date ASC', 'AsdBlog')), array(2, __('By page position DESC', 'AsdBlog')), array(3, __('By page position ASC', 'AsdBlog'))); $form->addField(new \Ip\Form\Field\Select(array('name' => 'data[blog][options][order]', 'label' => __('Order by', 'AsdBlog'), 'values' => $orderTypes))); $form->addField(new \Ip\Form\Field\Text(array('name' => 'data[blog][options][introlimit]', 'label' => __('Intro limit (if seperator is not placed)', 'AsdBlog'), 'value' => ipGetOption('AsdBlog.introLimit')))); $form->addField(new \Ip\Form\Field\Text(array('name' => 'data[blog][options][allowedtags]', 'label' => __('Allowed tags', 'AsdBlog'), 'note' => 'All other will be stripped', 'value' => ipGetOption('AsdBlog.allowedTags')))); $form->addField(new \Ip\Form\Field\Select(array('name' => 'data[blog][options][readmore]', 'label' => __('Show read more link?', 'AsdBlog'), 'values' => $yesNo, 'value' => ipGetOption('AsdBlog.showReadMore') == 'Yes' ? 1 : 0))); $form->addField(new \Ip\Form\Field\Select(array('name' => 'data[blog][options][titlelink]', 'label' => __('Show title as link to post?', 'AsdBlog'), 'values' => $yesNo, 'value' => ipGetOption('AsdBlog.addTitlelink') == 'Yes' ? 1 : 0))); $form->addField(new \Ip\Form\Field\Text(array('name' => 'data[blog][options][blockname]', 'label' => __('Post block name', 'AsdBlog'), 'value' => ipGetOption('AsdBlog.blockName')))); $yesNoUpBot = array(array(0, __('No', 'AsdBlog')), array(1, __('Yes, top', 'AsdBlog')), array(2, __('Yes, bottom', 'AsdBlog'))); $form->addFieldset(new \Ip\Form\Fieldset(__('Post aditional information', 'AsdBlog'))); $form->addField(new \Ip\Form\Field\Select(array('name' => 'data[blog][info][date]', 'label' => __('Show post date', 'AsdBlog'), 'values' => $yesNoUpBot, 'value' => ipGetOption('AsdBlog.showDate') == 'Yes' ? 1 : 0))); //This functionality will be added later // $form->addField(new \Ip\Form\Field\Select( // array( // 'name' => 'data[blog][info][time]', // 'label' => __( 'Show post time', 'AsdBlog' ), // 'values' => $yesNoUpBot, // 'value' => ipGetOption( 'AsdBlog.showTime' ) == 'Yes' ? 1 : 0 // ) // )); //This functionality will be added later // $form->addField(new \Ip\Form\Field\Select( // array( // 'name' => 'data[blog][info][author]', // 'label' => __( 'Show author name', 'AsdBlog' ), // 'values' => $yesNoUpBot, // ) // )); $form->addField(new \Ip\Form\Field\Select(array('name' => 'data[blog][info][category]', 'label' => __('Show category name', 'AsdBlog'), 'values' => $yesNoUpBot))); $form->addFieldset(new \Ip\Form\Fieldset(__('Image options', 'AsdBlog'))); $form->addField(new \Ip\Form\Field\Select(array('name' => 'data[blog][image][enable]', 'label' => __('Enable image', 'AsdBlog'), 'values' => $yesNo, 'note' => __('First image of post will be displayed', 'AsdBlog')))); $form->addField(new \Ip\Form\Field\Text(array('name' => 'data[blog][image][width]', 'label' => __('Image width', 'AsdBlog'), 'value' => ipGetOption('AsdBlog.imageWidth')))); $form->addField(new \Ip\Form\Field\Text(array('name' => 'data[blog][image][height]', 'label' => __('Image height', 'AsdBlog'), 'value' => ipGetOption('AsdBlog.imageHeight')))); return ipView('snippet/edit.php', array('form' => $form))->render(); }
public static function getMenusList() { if (ipGetOption('AsdMenuWidget.multilanguage') == 'Yes') { $multilanguage = null; } else { $languageCode = ipContent()->getCurrentLanguage()->code; $multilanguage = "`languageCode` = '{$languageCode}' AND"; } $table = ipTable('page'); $sql = "SELECT `title`, `alias`, `languageCode`, `parentId`, `id` FROM {$table} WHERE {$multilanguage} `isVisible` = 1 AND `isDeleted` = 0 ORDER BY `languageCode` ASC, `title` ASC"; $results = ipDb()->fetchAll($sql); foreach ($results as $result) { $allPages[$result['parentId']][$result['id']] = $result; } $returnData = makeMenu(0, $allPages, 0, $multilanguage); return $returnData; }
public static function getMenus() { $menuAliases = self::getMenuAliases(); $currLangCode = ipContent()->getCurrentLanguage()->getCode(); if (!empty($menuAliases)) { $menuPages = array(); foreach ($menuAliases as $menuAlias) { $menuRec = ipDb()->selectAll('page', 'id, title, alias', array('isDeleted' => 0, 'alias' => $menuAlias, 'parentId' => 0, 'isDisabled' => 0, 'isSecured' => 0, 'languageCode' => $currLangCode), 'ORDER BY `pageOrder`'); if (!empty($menuRec)) { $menuPages = array_merge($menuPages, $menuRec); } } } else { $menuPages = ipDb()->selectAll('page', 'id, title, alias', array('isDeleted' => 0, 'alias' => $menuAlias, 'parentId' => 0, 'isDisabled' => 0, 'isSecured' => 0, 'languageCode' => $currLangCode), 'ORDER BY `pageOrder`'); } return $menuPages; }
public function send() { ipContent()->setBlockContent('main', $this->content); if ($this->getLayout()) { $layout = $this->getLayout(); } else { $layout = 'main.php'; } if ($layout[0] == '/' || $layout[1] == ':') { // Check if absolute path: '/' for unix, 'C:' for Windows $viewFile = $layout; } else { $viewFile = ipThemeFile($layout); } $this->setContent(ipView($viewFile, $this->getLayoutVariables())->render()); $this->output(); }
/** * @desc Generate language selection menu * @author Allan Laal <*****@*****.**> * @param array $params * @return string */ public static function languages_80($params) { $data = array('languages' => ipContent()->getLanguages()); if (!is_array($params)) { $params = array(); } $data += $params; if (empty($data['attributes']) || !is_array($data['attributes'])) { $data['attributes'] = array(); } $data['attributesStr'] = join(' ', array_map(function ($sKey) use($data) { if (is_bool($data['attributes'][$sKey])) { return $data['attributes'][$sKey] ? $sKey : ''; } return $sKey . '="' . $data['attributes'][$sKey] . '"'; }, array_keys($data['attributes']))); return ipView('Ip/Internal/Config/view/languages.php', $data); }
public static function getKeywordData() { $pageTable = ipTable('page'); $keywordlistTable = ipTable(self::TABLE_NAME); $langCode = ipContent()->getCurrentLanguage()->getCode(); $excludeFields = ' AND p.IsVisible = 1 AND p.IsDisabled = 0 AND p.IsDeleted = 0'; $securedPages = ipGetOption('Keywordlist.securedPages') == 1 ? '' : 'AND p.IsSecured = 0'; if (ipGetOption('Keywordlist.useMetadata') == 1) { $sql = "SELECT p.id, p.title, p.urlPath, p.keywords, p.description FROM {$pageTable} p WHERE p.languageCode = '{$langCode}' AND p.keywords != '' {$excludeFields} {$securedPages}"; } else { $sql = "SELECT p.id, p.title, p.urlPath, k.keywords, k.description FROM {$pageTable} p, {$keywordlistTable} k WHERE p.id = k.pageid AND p.languageCode = '{$langCode}' AND k.keywords != '' {$excludeFields} {$securedPages}"; } $keywordArray = array(); $entries = array(); $entries = ipDb()->fetchAll($sql); $existingChars = array(); if (!empty($entries)) { // prepare array with keywords and pages $keywordArray = array(); $charSource = array('ä', 'ö', 'ü', 'ß', 'Ä', 'Ö', 'Ü'); $charReplace = array('a', 'o', 'u', 's', 'A', 'O', 'U'); foreach ($entries as $entry) { $keywords = array_map('trim', explode(",", $entry['keywords'])); foreach ($keywords as $keyword) { $firstChar = strtoupper(str_replace($charSource, $charReplace, mb_substr($keyword, 0, 1, 'UTF-8'))); if (is_numeric($firstChar)) { $firstChar = '0-9'; } $keywordArray[] = array('keyword' => $keyword, 'char' => $firstChar, 'id' => $entry['id'], 'title' => $entry['title'], 'description' => $entry['description'], 'urlPath' => $entry['urlPath']); } } // sorting keywordarray depending first char of keyword foreach ($keywordArray as $key => $row) { $char[$key] = $row['char']; } array_multisort($char, SORT_ASC, SORT_STRING, $keywordArray); $existingChars = array_unique($char); } $keywordData = array(); $keywordData['entries'] = $keywordArray; $keywordData['chars'] = $existingChars; return $keywordData; }
public static function ipBeforeController() { //show admin submenu if needed if (ipRoute()->isAdmin()) { ipAddJs('Ip/Internal/Core/assets/js/jquery-ui/jquery-ui.js'); ipAddCss('Ip/Internal/Core/assets/js/jquery-ui/jquery-ui.css'); $submenu = Submenu::getSubmenuItems(); $submenu = ipFilter('ipAdminSubmenu', $submenu); if ($submenu) { ipResponse()->setLayoutVariable('submenu', $submenu); } } // Show admin toolbar if admin is logged in: if (ipAdminId() && !ipRequest()->getRequest('pa') || ipRequest()->getRequest('aa') && ipAdminId()) { if (!ipRequest()->getQuery('ipDesignPreview') && !ipRequest()->getQuery('disableAdminNavbar')) { ipAddJs('Ip/Internal/Admin/assets/admin.js'); ipAddJsVariable('ipAdminNavbar', static::getAdminNavbarHtml()); } } // Show popup with autogenerated user information if needed $adminIsAutogenerated = ipStorage()->get('Ip', 'adminIsAutogenerated'); if ($adminIsAutogenerated) { $adminId = \Ip\Internal\Admin\Backend::userId(); $admin = \Ip\Internal\Administrators\Model::getById($adminId); ipAddJs('Ip/Internal/Admin/assets/adminIsAutogenerated.js'); $data = array('adminUsername' => $admin['username'], 'adminPassword' => ipStorage()->get('Ip', 'adminIsAutogenerated'), 'adminEmail' => $admin['email']); ipAddJsVariable('ipAdminIsAutogenerated', ipView('view/adminIsAutoGenerated.php', $data)->render()); } if (ipContent()->getCurrentPage()) { // initialize management if (ipIsManagementState()) { if (!ipRequest()->getQuery('ipDesignPreview') && !ipRequest()->getQuery('disableManagement')) { \Ip\Internal\Content\Helper::initManagement(); } } //show page content $response = ipResponse(); $response->setDescription(\Ip\ServiceLocator::content()->getDescription()); $response->setKeywords(ipContent()->getKeywords()); $response->setTitle(ipContent()->getTitle()); } }
public function getManagementPopupImage() { if (!isset($_POST['key'])) { throw new \Exception("Required parameter not set"); } $key = $_POST['key']; if (!isset($_POST['languageId'])) { throw new \Exception("Required parameter not set"); } $languageId = $_POST['languageId']; if (!isset($_POST['pageId'])) { throw new \Exception("Required parameter not set"); } $pageId = $_POST['pageId']; $imageStr = $this->dao->getValue(Dao::PREFIX_IMAGE, $key, $languageId, $pageId); $scope = $this->dao->getLastOperationScope(); $types = array(); $scopePageTitle = __('Current page and sub-pages', 'Ip-admin', false); $scopeParentPageTitle = __('Page "[[page]]" and all sub-pages', 'Ip-admin', false); $scopeLanguageTitle = __('All [[language]] pages', 'Ip-admin', false); $scopeAllPagesTitle = __('All pages', 'Ip-admin', false); $types[Scope::SCOPE_PAGE] = array('title' => $scopePageTitle, 'value' => Scope::SCOPE_PAGE); if ($scope && $scope->getType() == Scope::SCOPE_PARENT_PAGE) { $pageName = ''; $scopeParentPageTitle = str_replace('[[page]]', $pageName, $scopeParentPageTitle); $types[Scope::SCOPE_PARENT_PAGE] = array('title' => $scopeParentPageTitle, 'value' => Scope::SCOPE_PARENT_PAGE); } $scopeLanguageTitle = str_replace('[[language]]', ipContent()->getLanguage($languageId)->getAbbreviation(), $scopeLanguageTitle); $types[Scope::SCOPE_LANGUAGE] = array('title' => $scopeLanguageTitle, 'value' => Scope::SCOPE_LANGUAGE); $types[Scope::SCOPE_GLOBAL] = array('title' => $scopeAllPagesTitle, 'value' => Scope::SCOPE_GLOBAL); if ($scope && isset($types[$scope->getType()])) { $types[$scope->getType()]['selected'] = true; } else { $types[Scope::SCOPE_GLOBAL]['selected'] = true; } $popupData = array('types' => $types, 'showRemoveLink' => $imageStr !== false); $html = ipView('view/popup/image.php', $popupData)->render(); $image = new Entity\Logo($imageStr); $imageData = array('image' => $image->getImage() ? $image->getImage() : '', 'imageOrig' => $image->getImageOrig() ? $image->getImageOrig() : '', 'requiredWidth' => $image->getRequiredWidth(), 'requiredHeight' => $image->getRequiredHeight(), 'x1' => $image->getX1(), 'y1' => $image->getY1(), 'x2' => $image->getX2(), 'y2' => $image->getY2()); $data = array("status" => "success", "imageData" => $imageData, "html" => $html); return new \Ip\Response\Json($data); }
public function render($doctype, $environment) { $languages = ipContent()->getLanguages(); $answer = ''; foreach ($languages as $language) { $value = ipGetOptionLang($this->getOptionName(), $language->getCode(), $this->getValue()); $fieldId = $this->getName() . '_' . $language->getId() . ''; $answer .= ' <div class="input-group"> <span class="input-group-addon">' . esc($language->getAbbreviation()) . '</span> <input data-fieldname="' . $this->getName() . '" data-fieldid="' . $fieldId . '" id="' . $fieldId . '" ' . $this->getAttributesStr($doctype) . ' data-languageid="' . $language->getId() . '" class="ips' . $this->getName() . ' form-control ' . implode(' ', $this->getClasses()) . '" name="' . esc($fieldId, 'attr') . '" ' . $this->getValidationAttributesStr($doctype) . ' type="optionTextLang" value="' . esc($value, 'attr') . '" /> </div> '; } return $answer; }
public static function asd_menu($params) { $data = array('menu' => array('class' => 'menu', 'parent' => 'parent', 'active' => 'active', 'depth' => 0, 'hidechild' => 0), 'icon' => array('width' => 50, 'height' => 50, 'text' => false, 'empty' => false, 'enable' => false)); if (!empty($params['name'])) { $page = \Ip\Internal\Pages\Model::getPageByAlias(ipContent()->getCurrentLanguage()->getCode(), $params['name']); $data['menu']['name'] = $page['id']; } elseif (!empty($params['id'])) { $data['menu']['name'] = $params['id']; } if (!empty($params['class'])) { $data['menu']['class'] = $params['class']; } if (!empty($params['active'])) { $data['menu']['active'] = $params['active']; } if (!empty($params['parent'])) { $data['menu']['parent'] = $params['parent']; } if (!empty($params['depth'])) { $data['menu']['depth'] = $params['depth']; } if (!empty($params['nochild'])) { $data['menu']['nochild'] = $params['nochild']; } if (!empty($params['icon'])) { $data['icon']['enable'] = true; if (!empty($params['icon']['width'])) { $data['icon']['width'] = $params['icon']['width']; } if (!empty($params['icon']['height'])) { $data['icon']['height'] = $params['icon']['height']; } if (!empty($params['icon']['text'])) { $data['icon']['text'] = $params['icon']['text']; } if (!empty($params['icon']['empty'])) { $data['icon']['empty'] = $params['icon']['empty']; } } echo ipView('Widget/Menu/skin/default.php', array('data' => $data))->render(); }