public function SetBlockTypeProperties()
 {
     if (!ac_utils::is_frontend_request()) {
         $AC =& ac_utils::get_module('AdvancedContent');
         $multi_input_ids = ac_utils::CleanArray(explode(',', $this->GetProperty('inputs')));
         $blockType =& acContentBlockManager::GetBlockType('multi_input');
         $multiInput_props = $blockType['props'];
         foreach ($multi_input_ids as $k1 => $multi_input_id) {
             if (!isset($multiInput_props[$multi_input_id])) {
                 $multiInput_props = array_merge($multiInput_props, ac_admin_ops::GetMultiInputFull($multi_input_ids));
                 if (!isset($multiInput_props[$multi_input_id])) {
                     continue;
                 }
                 $multiInput_props[$multi_input_id]['template'] = $AC->GetTemplate($multiInput_props[$multi_input_id]['tpl_name']);
                 $matches = array();
                 $result = preg_match_all(AC_BLOCK_PATTERN, $multiInput_props[$multi_input_id]['input_fields'], $matches);
                 if ($result && count($matches[1]) > 0) {
                     foreach ($matches[1] as $k2 => $wholetag) {
                         if (!($inputBlock = acContentBlockManager::CreateContentBlock($this->content_obj, acContentBlockManager::GetTagParams($wholetag)))) {
                             continue;
                         }
                         if ($inputBlock->Type() == 'multi_input') {
                             continue;
                         }
                         # ToDo: display message?
                         $multiInput_props[$multi_input_id]['elements'][$k2] = $inputBlock;
                     }
                 }
             }
         }
         acContentBlockManager::SetBlockTypeProperties('multi_input', $multiInput_props);
     }
 }
 /**
  * Not part of the api
  */
 private function _get_items_array($selItems = array())
 {
     $AC =& ac_utils::get_module('AdvancedContent');
     $items = array();
     if ($this->GetProperty('items') != '') {
         foreach (explode($this->GetProperty('delimiter'), $this->GetProperty('items')) as $key => $val) {
             $items[$key]['id'] = munge_string_to_url(trim($val));
             $items[$key]['label'] = trim($val);
             if ($this->GetProperty('translate_labels')) {
                 $items[$key]['label'] = $AC->lang($items[$key]['label']);
             }
             $items[$key]['value'] = $items[$key]['label'];
             $items[$key]['selected'] = in_array($items[$key]['label'], $selItems);
         }
     }
     if ($this->GetProperty('values') != '') {
         foreach (explode($this->GetProperty('delimiter'), $this->GetProperty('values')) as $key => $val) {
             $items[$key]['value'] = trim($val);
             if ($this->GetProperty('translate_values')) {
                 $items[$key]['value'] = $AC->lang($items[$key]['value']);
             }
             $items[$key]['selected'] = in_array($items[$key]['value'], $selItems);
             if (!isset($items[$key]['label'])) {
                 $items[$key]['label'] = $items[$key]['value'];
             }
         }
     }
     return $items;
 }
 public function GetInput()
 {
     $AC =& ac_utils::get_module('AdvancedContent');
     if ($this->GetProperty('module') == '') {
         return $AC->lang('error_insufficient_blockparams', 'module', $this->GetProperty('name'));
     }
     if (!($module =& $AC->GetModuleInstance($this->GetProperty('module')))) {
         return $AC->lang('error_loading_module', $this->GetProperty('module'), $this->GetProperty('name'));
     }
     if (!$module->HasCapability('contentblocks')) {
         return $AC->lang('error_contentblock_support', $this->GetProperty('module'), $this->GetProperty('name'));
     }
     return $module->GetContentBlockInput($this->GetProperty('id'), $this->GetContent(), $this->GetProperty('params'), $this->GetProperty('adding'));
 }
 function __construct(&$content_obj, $params = array())
 {
     parent::__construct($content_obj, $params);
     $AC =& ac_utils::get_module('AdvancedContent');
     $this->SetProperty('no_collapse', true);
     $this->SetProperty('collapsible', false);
     $this->SetProperty('collapse', false);
     if ($this->content_obj->IsKnownProperty($this->GetProperty('id'))) {
         $this->SetProperty('error_message', $AC->lang('error_basicattrib', $this->GetProperty('name')));
     } else {
         $this->SetProperty('error_message', $AC->lang('invalid_block', $this->GetProperty('name'), $this->Type()));
     }
     $this->SetContent('');
 }
 public function GetInput()
 {
     $AC =& ac_utils::get_module('AdvancedContent');
     $items = array();
     if ($this->GetProperty('items') != '') {
         foreach (explode($this->GetProperty('delimiter'), $this->GetProperty('items')) as $key => $val) {
             $items[$key]['label'] = trim($val);
             if ($this->GetProperty('translate_labels')) {
                 $items[$key]['label'] = $AC->lang($items[$key]['label']);
             }
             $items[$key]['value'] = $items[$key]['label'];
             $items[$key]['selected'] = trim($this->GetContent()) === $items[$key]['value'];
         }
     }
     if ($this->GetProperty('values') != '') {
         foreach (explode($this->GetProperty('delimiter'), $this->GetProperty('values')) as $key => $val) {
             $items[$key]['value'] = trim($val);
             if ($this->GetProperty('translate_values')) {
                 $items[$key]['value'] = $AC->lang($items[$key]['value']);
             }
             $items[$key]['selected'] = trim($this->GetContent()) === $items[$key]['value'];
             if (!isset($items[$key]['label'])) {
                 $items[$key]['label'] = $items[$key]['value'];
             }
         }
     }
     $input = '<select name="' . $this->GetProperty('id') . '" ' . ($this->GetProperty('style') != '' ? 'style="' . $this->GetProperty('style') . ' "' : '') . ' >';
     foreach ($items as $item) {
         $input .= '<option value="' . $item['value'] . '"';
         if ($item['selected']) {
             $input .= ' selected="selected"';
         }
         $input .= '>' . $item['label'] . '</option>';
     }
     $input .= '</select>';
     return $input;
 }
 /**
  * @internal
  * @access private
  */
 public static function _register_content_block(&$content_obj, &$contentBlock)
 {
     # do not process blocks with same id twice
     if (isset(self::$_content_blocks[$content_obj->Id()][$contentBlock->GetProperty('id')])) {
         self::$_content_blocks[$content_obj->Id()][$contentBlock->GetProperty('id')]->SetProperty('multiple', true);
         return;
     }
     $AC =& ac_utils::get_module('AdvancedContent');
     $block_id = $contentBlock->GetProperty('id');
     # this block has been added to the template after page has been created?
     if (!$content_obj->HasProperty($block_id)) {
         $contentBlock->SetProperty('new_block', true);
     }
     # ToDo: how remove the backend stuff from this class without need to loop through all content blocks again?
     if (!ac_utils::is_frontend_request()) {
         $type = $contentBlock->Type();
         if (!isset(self::$_block_types[$type])) {
             self::$_block_types[$type] = array('content_blocks' => array(), 'header_html_called' => false, 'props' => array());
         }
         self::$_block_types[$type]['content_blocks'][$block_id] = $block_id;
         acTabManager::SetTabs($content_obj, $contentBlock);
         if ($contentBlock->Type() != AC_INVALID_BLOCK_TYPE) {
             if ($contentBlock->GetProperty('smarty')) {
                 foreach ($contentBlock->GetProperties() as $propName => $propValue) {
                     $contentBlock->SetProperty($propName, ac_utils::DoSmarty($content_obj, $propValue));
                 }
             }
             $value = $contentBlock->GetContent();
             if ($content_obj->Id() < 0 && $value == '' || $value == '' && !$contentBlock->GetProperty('allow_none') || $contentBlock->GetProperty('new_block')) {
                 $value = $contentBlock->GetProperty('default');
             }
             $content_obj->SetPropertyValueNoLoad($block_id, $value);
             $block_display = true;
             if ($contentBlock->GetProperty('collapsible')) {
                 $block_display = ac_admin_ops::GetVisibility('block', $block_id, $content_obj->Id(), $content_obj->TemplateId(), !$contentBlock->GetProperty('collapse'));
                 $contentBlock->SetProperty('pref_url', str_replace('&amp);', '&', $AC->CreateLink('m1_', 'savePrefs', '', $AC->lang('toggle_block'), array('item_type' => 'block', 'disable_theme' => true, 'edit_content' => true, 'content_id' => $content_obj->Id(), 'template_id' => $content_obj->TemplateId(), 'item_id' => $block_id, 'item_display' => !$block_display), '', true)));
             }
             $contentBlock->SetProperty('display', $block_display);
         }
         if (strtolower($contentBlock->GetProperty('label')) == 'content_en') {
             $contentBlock->SetProperty('label', lang('content'));
         }
         if ($contentBlock->GetProperty('translate_labels')) {
             $contentBlock->SetProperty('label', $AC->lang($contentBlock->GetProperty('label')));
         }
         # deprecated (should not be needed since CMSms 1.11)
         if ($contentBlock->GetProperty('multiple') && ac_admin_ops::GetVisibility('message', $block_id, $content_obj->Id(), $content_obj->TemplateId())) {
             $hide_link = str_replace('&amp;', '&', $AC->CreateLink('m1_', 'savePrefs', '', $AC->lang('toggle_message'), array('item_type' => 'message', 'disable_theme' => true, 'edit_content' => true, 'content_id' => $content_obj->Id(), 'template_id' => $content_obj->TemplateId(), 'item_id' => $block_id, 'item_display' => 0), '', false, '', 'onclick="jQuery.get(this.href); jQuery(\'#' . $block_id . '_message\').toggle(\'fast\',function(){jQuery(this).remove()}); return false;"'));
             $contentBlock->SetProperty('message', $AC->lang('notice_duplicatecontent', $contentBlock->GetProperty('name')) . ' (' . $hide_link . ')');
         }
         #---
         $contentBlock->SetBlockTypeProperties();
     }
     if ($contentBlock->Type() != AC_INVALID_BLOCK_TYPE && ac_utils::is_frontend_request() || !ac_utils::is_frontend_request()) {
         $content_obj->AddExtraProperty($block_id);
         # backward compatibility (deprecated)
         self::$_content_blocks[$content_obj->Id()][$block_id] = $contentBlock;
     }
 }
예제 #7
0
 public static function EditAsArray(&$content_obj, $adding = false, $tab = 0, $showadmin = false)
 {
     if (!($tab_id = acTabManager::GetTabId($tab))) {
         return array();
     }
     $AC =& ac_utils::get_module('AdvancedContent');
     $ret = array();
     $tmp = array();
     if ($tab_id == 'main' || $tab_id == 'options' && check_permission(get_userid(), 'Manage All Content')) {
         $tmp = ac_utils::CleanArray($content_obj->DisplayAttributes($adding, $tab));
     } else {
         if ($tab_id == 'AdvancedContent') {
             $tmp = self::DisplayAdvancedOptions($content_obj, $adding);
         }
     }
     foreach ($tmp as $one) {
         $ret[] = $one;
     }
     $AC->smarty->assign_by_ref('content_obj', $content_obj);
     $AC->smarty->assign('tab', acTabManager::GetTab($tab_id));
     $AC->smarty->assign('locale', substr(get_preference(get_userid(), 'default_cms_language'), 0, 2));
     if ($tab == 0) {
         $html = $AC->GetHeaderHTML() . '<!-- start ac blocktypes head -->';
         $blockTypes =& acContentBlockManager::GetBlockTypes();
         foreach ($blockTypes as &$btype) {
             if ($btype['header_html_called']) {
                 continue;
             }
             $btype['header_html_called'] = true;
             $blocks = $btype['content_blocks'];
             $block_id = array_shift($blocks);
             $contentBlock =& $content_obj->GetContentBlock($block_id);
             if ($contentBlock->Type() == AC_INVALID_BLOCK_TYPE) {
                 continue;
             }
             $html .= $contentBlock->GetHeaderHTML();
         }
         echo $html . '<!-- end ac blocktypes head -->';
     }
     $ret[] = array('', $AC->ProcessTemplate('editcontent.tpl'));
     return $ret;
 }
예제 #8
0
} elseif (isset($_REQUEST['mact'])) {
    $ary = explode(',', cms_htmlentities($_REQUEST['mact']), 4);
    $modulename = isset($ary[0]) ? $ary[0] : '';
    $id = isset($ary[1]) ? $ary[1] : '';
    $action = isset($ary[2]) ? $ary[2] : '';
    $inline = isset($ary[3]) && $ary[3] == 1 ? true : false;
}
if (isset($_REQUEST[$id . 'action'])) {
    $action = $_REQUEST[$id . 'action'];
} else {
    if (isset($_REQUEST['action'])) {
        $action = $_REQUEST['action'];
    }
}
if ($block == 'content_en' && ($id == 'cntnt01' || $id == '_preview_' || $id != '' && $inline == false)) {
    $module =& ac_utils::get_module($modulename);
    if (is_object($module) && $module->IsPluginModule()) {
        @ob_start();
        $params = GetModuleParameters($id);
        $returnid = isset($params['returnid']) ? $params['returnid'] : $content_obj->Id();
        $output = $module->DoActionBase($action, $id, $params, $returnid);
        if ($output !== FALSE && (!isset($params['no_output']) || ac_utils::IsFalse($params['no_output']))) {
            echo $output;
        }
        $output = @ob_get_contents();
        @ob_end_clean();
    }
} else {
    $oldvalue = cmsms()->GetSmarty()->caching;
    cmsms()->GetSmarty()->caching = false;
    $contentId = $content_obj->Id();
 /**
  * Function for the subclass to perform the blocks compiled output in frontend.<br />
  * Needs to be overwritten if the blocktype provides a special kind of data that needs to be processed before compiling it in frontend.
  * @param $obj
  * @return string
  * @since 0.9.4
  */
 public function GetCompiledContent(&$obj)
 {
     $id = '';
     $modulename = '';
     $action = '';
     $inline = false;
     if (isset($_REQUEST['module'])) {
         $modulename = $_REQUEST['module'];
     }
     if (isset($_REQUEST['id'])) {
         $id = $_REQUEST['id'];
     } elseif (isset($_REQUEST['mact'])) {
         $ary = explode(',', cms_htmlentities($_REQUEST['mact']), 4);
         $modulename = isset($ary[0]) ? $ary[0] : '';
         $id = isset($ary[1]) ? $ary[1] : '';
         $action = isset($ary[2]) ? $ary[2] : '';
         $inline = isset($ary[3]) && $ary[3] == 1 ? true : false;
     }
     if (isset($_REQUEST[$id . 'action'])) {
         $action = $_REQUEST[$id . 'action'];
     } else {
         if (isset($_REQUEST['action'])) {
             $action = $_REQUEST['action'];
         }
     }
     if ($this->_properties['id'] == 'content_en' && ($id == 'cntnt01' || $id == '_preview_' || $id != '' && $inline == false)) {
         $module =& ac_utils::get_module($modulename);
         if (is_object($module) && $module->IsPluginModule()) {
             @ob_start();
             $params = GetModuleParameters($id);
             $returnid = isset($params['returnid']) ? $params['returnid'] : $this->content_obj->Id();
             echo $module->DoActionBase($action, $id, $params, $returnid);
             $output = @ob_get_contents();
             @ob_end_clean();
         }
     } else {
         if (version_compare(CMS_VERSION, '1.11') < 0) {
             $smarty =& $obj;
         } else {
             $smarty =& $obj->smarty;
         }
         $oldvalue = $smarty->caching;
         $smarty->caching = false;
         if ($id == '_preview_' || $id == '') {
             $output = $smarty->fetch('string:' . $this->GetContent());
         } else {
             $output = $smarty->fetch(str_replace(' ', '_', 'content:' . $this->_properties['id']), '|' . $this->_properties['id'], $this->content_obj->Id() . $this->_properties['id']);
         }
         $smarty->caching = $oldvalue;
         if ($output == '' && !$this->_properties['allow_none']) {
             $output = $this->_properties['default'];
         }
     }
     if (!empty($this->_properties['assign'])) {
         $smarty->assign($this->_properties['assign'], $output);
         return '';
     }
     return trim($output);
 }
예제 #10
0
 private static function _set_block_group($content_obj, &$contentBlock)
 {
     if ($contentBlock->GetProperty('block_group') == '') {
         return;
     }
     $AC =& ac_utils::get_module('AdvancedContent');
     $page_tab_id = $contentBlock->GetProperty('page_tab');
     $block_tab_id = $contentBlock->GetProperty('block_tab');
     $group_name = $contentBlock->GetProperty('block_group');
     $group_id = ($block_tab_id ? $block_tab_id : $page_tab_id) . '_' . ac_utils::CleanStrId($group_name);
     $tab_array = $block_tab_id ? self::$_tabs[$page_tab_id]['block_tabs'][$block_tab_id]['block_groups'] : self::$_tabs[$page_tab_id]['block_groups'];
     if (!isset($tab_array[$group_id])) {
         $collapsible = $contentBlock->GetProperty('collapsible');
         $group_display = $collapsible ? ac_admin_ops::GetVisibility('group', $group_id, $content_obj->Id(), $content_obj->TemplateId(), !$AC->GetPreference('collapse_group_default', 1)) : true;
         $pref_url = $collapsible ? str_replace('&amp;', '&', $AC->CreateLink('m1_', 'savePrefs', '', $AC->lang('toggle_group'), array('item_type' => 'group', 'disable_theme' => true, 'edit_content' => true, 'content_id' => $content_obj->Id(), 'template_id' => $content_obj->TemplateId(), 'item_id' => $group_id, 'item_display' => !$group_display), '', true)) : '#';
         $tab_array[$group_id] = array('group_id' => $group_id, 'group_name' => $group_name, 'collapsible' => $collapsible, 'display' => $group_display, 'pref_url' => $pref_url);
     }
     $block_id = $contentBlock->GetProperty('id');
     $tab_array[$group_id]['content_blocks'][$block_id] = $block_id;
     if ($block_tab_id) {
         self::$_tabs[$page_tab_id]['block_tabs'][$block_tab_id]['block_groups'] = $tab_array;
         unset(self::$_tabs[$page_tab_id]['block_tabs'][$block_tab_id]['content_blocks'][$block_id]);
     } else {
         self::$_tabs[$page_tab_id]['block_groups'] = $tab_array;
     }
     unset(self::$_tabs[$page_tab_id]['content_blocks'][$block_id]);
 }
 /**
  * Just a wrapper to get a module instance in the template
  *
  * @param string $module_name - the exact name of the module (case sensitive)
  * @param string $module_version (optional) - the minimum version of the module
  * @return object
  */
 public function &get_module($module_name, $module_version = '')
 {
     return ac_utils::get_module($module_name, $module_version);
 }