function test_mix_of_self_closing_and_enclosing_shortcodes() { $before = 'Content with nested [shortcode]Inside [shortcode] content[bold]bold text[/bold] and a random square bracket[/shortcode]'; $after = 'Content with nested Inside [shortcode] content[bold]bold text[/bold] and a random square bracket'; $cleaner = get_plugin('cleaner'); $this->assertEquals($after, $cleaner->remove_enclosing_shortcode('shortcode', $before)); }
function test_square_brackets_in_enclosing_shortcode() { $before = 'Content with nested [shortcode]Inside content[bold]bold text[/bold] and a random square bracket[/shortcode]'; $after = 'Content with nested Inside content[bold]bold text[/bold] and a random square bracket'; $cleaner = get_plugin('cleaner'); // @todo do we need to flip these so expected/actual line up? $this->assertEquals($after, $cleaner->remove_shortcode('shortcode', $before)); }
function VarDefHandler($module, $meta_array_name = null) { $this->meta_array_name = $meta_array_name; $this->module_object = $module; if ($meta_array_name != null) { global $vardef_meta_array; include "include/VarDefHandler/vardef_meta_arrays.php"; //BEGIN WFLOW PLUGINS get_plugin("workflow", "vardef_handler_hook", $this); //END WFLOW PLUGINS $this->target_meta_array = $vardef_meta_array[$meta_array_name]; } //end function setup }
function check_installed_plugin_versions($plugin, $wcp_top) { $plugin_manifest = ''; $plugin->folder = $wcp_top . $plugin->group . "/" . $plugin->id; $dbg_msg = sprintf("%s: group='%s', folder='%s', manifest='", $plugin->id, $plugin->group, $plugin->folder); if (file_exists($plugin->folder) && is_dir($plugin->folder)) { $plugin->installed = "YES"; $plugin_manifest = $plugin->folder . "/" . $plugin->id . ".manifest"; if (file_exists($plugin_manifest) && !is_dir($plugin_manifest)) { $installed_plugin = get_plugin($plugin_manifest); $plugin->installedVersion = $installed_plugin->plugin_version; } else { $plugin->installedVersion = "unknown"; } } $dbg_msg .= sprintf("%s', installed='%s', installedVers='%s'<br/>", $plugin_manifest, $plugin->installed, $plugin->installedVersion); return $dbg_msg; }
function get_list_view_data() { global $app_strings, $mod_strings; global $app_list_strings; global $mod_strings; global $beanList; global $current_module_strings2; global $current_user; /* ///Determine Natural Language to display if($this->action_type=='new'){ $natural_language = $current_module_strings['LBL_ACTION_NEW']." ".$beanList[$this->action_module]; } if($this->action_type=='update_rel'){ $workflow_object = $this->get_workflow_object(); $rel_module = $workflow_object->get_rel_module($this->rel_module); $natural_language = $current_module_strings['LBL_ACTION_UPDATE_REL']." ".$rel_module; unset($workflow_object); } if($this->action_type=='update'){ $natural_language = $current_module_strings['LBL_ACTION_UPDATE']." ".$current_module_strings['LBL_RECORD']; } */ //begin - rsmith include_once 'include/ListView/ProcessView.php'; $ProcessView = new ProcessView($this->get_workflow_object(), $this); $results = $ProcessView->get_action_shell_display_text($this, false); $result = $results["RESULT_ARRAY"]; $table_html = "<table id='tbl_{$this->id}' style='display:none'>"; foreach ($result as $key => $value) { if (isset($value["ACTION_DISPLAY_TEXT"])) { if ($value["ACTION_DISPLAY_TEXT"] === false) { $table_html .= "<tr><td>"; $table_html .= "<span class='error'>" . translate('LBL_ACTION_ERROR') . "</span>"; $table_html .= "</td></tr>"; if (empty($this->hasError)) { $this->hasError = true; echo '<p class="error"><b>' . translate('LBL_ACTION_ERRORS') . '</b></p>'; } } else { $table_html .= "<tr><td>"; $table_html .= "<li>" . $mod_strings['LBL_SET'] . " " . $value["FIELD_NAME"] . " " . $mod_strings['LBL_AS'] . " " . $value["ACTION_DISPLAY_TEXT"]; $table_html .= "</td></tr>"; } } } $table_html .= "</table>"; //end - rsmith $temp_array = array(); //Grab event $ProcessView->local_strings = $current_module_strings2; //BEGIN WFLOW PLUGINS global $process_dictionary; get_plugin("workflow", "action_createstep1", $this); //END WFLOW PLUGINS $prev_display_text = $ProcessView->get_prev_text("ActionsCreateStep1", $this->action_type); unset($ProcessView); //$natural_language = "<i>".$current_module_strings['LBL_LIST_STATEMENT_CONTENT']."</i>"; $natural_language = "<b>" . $prev_display_text . "</b>"; $temp_array['HREF_EDIT'] = "'javascript:get_popup(\"" . $this->parent_id . "\",\"" . $this->id . "\",\"CreateStep2\",\"\",\"\",\"400\",\"500\")'"; $temp_array['HREF_DELETE'] = "index.php?action=Delete&module=WorkFlowActionShells&record=" . $this->id . ""; $temp_array['TYPE'] = $current_module_strings2['LBL_MODULE_NAME']; $temp_array['STATEMENT'] = "<i>" . $natural_language . "</i>"; $temp_array['DETAILS_TABLE'] = $table_html; //$temp_array['ACTION_DESCRIPTION'] = "<i>".$natural_language."</i>"; $temp_array['ID'] = $this->id; //Component information for either invitees (Meetings & Calls ONLY) if ($this->action_module == "Meetings" || $this->action_module == "Calls" || $this->action_module == "meetings" || $this->action_module == "calls") { $recipient_icon = SugarThemeRegistry::current()->getImage('Users', 'align="absmiddle" border="0"', null, null, '.gif', $app_strings['LNK_REMOVE']); $bridge_list = $this->get_linked_beans("action_bridge", "WorkFlow"); if (!empty($bridge_list)) { $alertshell_list = $bridge_list[0]->get_linked_beans("alerts", "WorkFlowAlertShell"); if (!empty($alertshell_list)) { //check for any invitees $invitees_list = $alertshell_list[0]->get_linked_beans('alert_components', 'WorkFlowAlert'); if (empty($invitees_list)) { $invitee_notice = "<font color='red'><b>" . $mod_strings['LBL_INVITEE_NOTICE'] . " " . $app_list_strings['moduleListSingular'][ucfirst($this->action_module)] . " </b></font><BR>"; $temp_array['STATEMENT_NOTICE'] = $invitee_notice; } $temp_array['COMPONENT_HREF_EDIT'] = 'index.php?action=DetailView&module=WorkFlowAlertShells&module_tab=WorkFlow&record=' . $alertshell_list[0]->id . '&workflow_id=' . $alertshell_list[0]->parent_id; $temp_array['COMPONENT_STATEMENT'] = $recipient_icon . $mod_strings['LBL_INVITEES']; } } } //BEGIN WFLOW PLUGINS $list_data_array = get_plugin("workflow", "action_listview", $this); if (!empty($list_data_array['action_processed']) && $list_data_array['action_processed'] == true) { //a custom plugin was found with data foreach ($list_data_array['list_data'] as $list_key => $list_value) { $temp_array[$list_key] = $list_value; //loop through and fill the temp_array } } //END WFLOW PLUGINS return $temp_array; }
/** * Run Genesis Header Nav plugin. * * @since 2.0.0 */ function genesis_header_nav_run() { $plugin = get_plugin(); $plugin->run(); }
if (!is_file(sugar_cached('jsLanguage/WorkFlow/') . $GLOBALS['current_language'] . '.js')) { require_once 'include/language/jsLanguage.php'; jsLanguage::createModuleStringsCache('WorkFlow', $GLOBALS['current_language']); } $javascript_language_files .= getVersionedScript("cache/jsLanguage/WorkFlow/{$GLOBALS['current_language']}.js", $GLOBALS['sugar_config']['js_lang_version']); $the_javascript = "<script type='text/javascript' language='JavaScript'>\n"; $the_javascript .= "function set_return() {\n"; $the_javascript .= " window.opener.document.EditView.submit();"; $the_javascript .= "}\n"; $the_javascript .= "</script>\n"; $form->assign("ID", $focus->id); $form->assign("WORKFLOW_ID", $_REQUEST['workflow_id']); $form->assign("BASE_MODULE", $seed_object->base_module); //BEGIN - WFLOW PLUGINS INFORMATION////// global $process_dictionary; $plugin_array = get_plugin("workflow", "action_createstep1", $focus); if (!empty($plugin_array)) { $form->assign("PLUGIN_JAVASCRIPT1", $plugin_array['jscript_part1']); $form->assign("PLUGIN_JAVASCRIPT2", $plugin_array['jscript_part2']); } //END - WFLOW PLUGINS INFORMATION////// $form->assign("JAVASCRIPT_LANGUAGE_FILES", $javascript_language_files); $form->assign("MODULE_NAME", $currentModule); //$form->assign("FORM", $_REQUEST['form']); $form->assign("GRIDLINE", $gridline); $form->assign("SET_RETURN_JS", $the_javascript); insert_popup_header($theme); $form->parse("embeded"); $form->out("embeded"); //////////New way of processing page require_once 'include/ListView/ProcessView.php';
function get_list_view_data() { global $app_strings, $mod_strings; global $app_list_strings; global $current_user; global $current_module_strings; $temp_array = array(); //BEGIN WFLOW PLUGINS global $process_dictionary; get_plugin("workflow", "trigger_createstep1", $this); //END WFLOW PLUGINS //Grab event include_once 'include/ListView/ProcessView.php'; $ProcessView = new ProcessView($this->get_workflow_type(), $this); $ProcessView->local_strings = $current_module_strings; $prev_display_text = $ProcessView->get_prev_text("TriggersCreateStep1", $this->type); // Added a text add to the confirmation of deletes when deleting a primary trigger $deleteConfirm = $current_module_strings['NTC_REMOVE_TRIGGER']; if ($this->frame_type == "Primary") { $statement1 = $current_module_strings['LBL_LIST_STATEMEMT']; // Add a notice that deleting the primary deletes all triggers $deleteConfirm .= ' ' . $current_module_strings['NTC_REMOVE_TRIGGER_PRIMARY']; } else { $statement1 = $current_module_strings['LBL_FILTER_LIST_STATEMEMT']; } $temp_array['REMOVE_TRIGGER_CONFIRM'] = $deleteConfirm; $temp_array['FRAME_TYPE'] = $this->frame_type; $temp_array['STATEMENT'] = "<b>" . $prev_display_text . "</b>"; $temp_array['STATEMENT1'] = "<i>" . $statement1 . "</i>"; $trigger_display_text = $ProcessView->get_trigger_display_text("TriggersCreateStep1", $this); if (strpos($trigger_display_text, 'class="error"') !== false && empty($this->hasError)) { $this->hasError = true; echo '<p class="error"><b>' . translate('LBL_TRIGGER_ERRORS') . '</b></p>'; } $temp_array['STATEMENT2'] = "<b>" . $trigger_display_text . "</b>"; unset($ProcessView); //preset height and width $temp_array['POPUP_HEIGHT'] = "500"; $temp_array['POPUP_WIDTH'] = "400"; $action_processed = false; if ($this->type == "compare_change" || $this->type == "trigger_record_change") { $temp_array['ACTION'] = 'CreateStep1'; $action_processed = true; } if ($this->type == "compare_specific") { $temp_array['ACTION'] = 'CreateStepSpecific'; $action_processed = true; } if ($this->type == "compare_count") { $temp_array['ACTION'] = 'CreateStepCount'; $action_processed = true; } if ($this->type == "compare_any_time") { $temp_array['ACTION'] = 'CreateStep1'; $action_processed = true; } if ($this->type == "filter_field" || $this->type == "filter_rel_field") { $temp_array['ACTION'] = 'CreateStepFilter'; $action_processed = true; } //BEGIN WFLOW PLUGINS if ($action_processed == false) { $list_data_array = get_plugin("workflow", "trigger_listview", $this); if (!empty($list_data_array['action_processed']) && $list_data_array['action_processed'] == true) { //a custom plugin was found with data foreach ($list_data_array['list_data'] as $list_key => $list_value) { $temp_array[$list_key] = $list_value; //loop through and fill the temp_array } } } //END WFLOW PLUGINS $temp_array['PARENT_ID'] = $this->parent_id; $temp_array['ID'] = $this->id; return $temp_array; }
function get_action_contents($workflow_id, $trigger_count, $action_module_name) { $action_count = 0; $action_string = ""; $query = "\tSELECT *\n\t\t\t\t\tFROM {$this->rel_actionshells_table}\n\t\t\t\t\tWHERE deleted = 0\n\t\t\t\t\tAND parent_id = '" . $workflow_id . "'\n\t\t\t\t "; $result = $this->db->query($query, true, " Error getting trigger action shells for shell write: "); // Get the id and the name. while ($row = $this->db->fetchByAssoc($result)) { $process = true; if ($row['action_type'] == "new" && ($row['action_module'] == "Calls" || $row['action_module'] == "Meetings" || $row['action_module'] == "calls" || $row['action_module'] == "meetings")) { $actionshell_object = BeanFactory::getBean('WorkFlowActionShells'); $process = $actionshell_object->check_for_child_invitee($row['id']); //end special child check for meetings/calls } if ($process == true) { $plugin_process = false; //BEGIN WFLOW PLUGINS //prepare the opt array $opt['object'] = $this; $opt['row'] = $row; $opt['array_position_name'] = "plugin_" . $trigger_count . "_action" . $action_count; $action_output_array = get_plugin("workflow", "action_glue", $opt); if (!empty($action_output_array['action_processed']) && $action_output_array['action_processed'] == true) { $action_string .= $action_output_array['action_string']; $plugin_process = true; ++$action_count; //end if processed is true } //END WFLOW PLUGINS if ($plugin_process == false) { $array_position_name = $action_module_name . "" . $trigger_count . "_action" . $action_count; $this->glue_object->build_trigger_actions($row['id'], $array_position_name, $row); $action_string .= "\t process_workflow_actions(\$focus, \$action_meta_array['" . $array_position_name . "']); \n "; ++$action_count; } //end if process is true } //end while statement } return $action_string; //end function get_alert_contents }
jsLanguage::createAppStringsCache($GLOBALS['current_language']); } $javascript_language_files = getVersionedScript("cache/jsLanguage/{$GLOBALS['current_language']}.js", $GLOBALS['sugar_config']['js_lang_version']); if (!is_file(sugar_cached('jsLanguage/') . $this->module . '/' . $GLOBALS['current_language'] . '.js')) { require_once 'include/language/jsLanguage.php'; jsLanguage::createModuleStringsCache($this->module, $GLOBALS['current_language']); } $javascript_language_files .= getVersionedScript("cache/jsLanguage/{$this->module}/{$GLOBALS['current_language']}.js", $GLOBALS['sugar_config']['js_lang_version']); $the_javascript = "<script type='text/javascript' language='JavaScript'>\n"; $the_javascript .= "function set_return() {\n"; $the_javascript .= " window.opener.document.EditView.submit();"; $the_javascript .= "}\n"; $the_javascript .= "</script>\n"; //BEGIN - WFLOW PLUGINS INFORMATION////// global $process_dictionary; $plugin_array = get_plugin("workflow", "trigger_createstep1", $focus); if (!empty($plugin_array)) { $form->assign("PLUGIN_JAVASCRIPT1", $plugin_array['jscript_part1']); $form->assign("PLUGIN_JAVASCRIPT2", $plugin_array['jscript_part2']); } //END - WFLOW PLUGINS INFORMATION////// $form->assign("MOD", $mod_strings); $form->assign('JS_INCLUDE', $js_include); $form->assign("APP", $app_strings); $form->assign("JAVASCRIPT_LANGUAGE_FILES", $javascript_language_files); $form->assign("MODULE_NAME", $currentModule); $form->assign("GRIDLINE", $gridline); $form->assign("SET_RETURN_JS", $the_javascript); $form->assign("SUGAR_VERSION", $sugar_version); $form->assign("JS_CUSTOM_VERSION", $sugar_config['js_custom_version']); $form->assign("BASE_MODULE", $workflow_object->base_module);
function test_invalid_properties_throw_errors() { $this->setExpectedException('\\Exception'); get_plugin('i.dont.exist'); }
$plugin = new Plugin(); $plugin->setup(__FILE__); } if (!is_null($plugin_part)) { $current_class = $plugin; $classes = explode('.', $plugin_part); $property = array_pop($classes); // Find the innermost class if (!empty($classes)) { foreach ($classes as $class) { if (property_exists($current_class, $class)) { if (!is_object($current_class->{$class})) { $current_class_name = get_class($current_class); throw new \Exception("{$class} is not an object within {$current_class_name}"); } $current_class = $current_class->{$class}; } } } // Get the property, now that we have the innermost class if (!property_exists($current_class, $property)) { $current_class_name = get_class($current_class); throw new \Exception("{$property} is not a part of {$current_class_name}"); } return $current_class->{$property}; } return $plugin; } // Gets the whole process rolling get_plugin();
/** * returns text that describes the action * @param WorkFlowActionShell $action_shell - the WorkFlowActionShell to use to process * @return an array containing the relevant data for use in UI * @access public */ function get_action_shell_display_text($action_shell, $get_all_fields = true) { $action_processed = false; $workflow_object = $action_shell->get_workflow_object(); if ($action_shell->action_type == "update") { $temp_module = BeanFactory::getBean($workflow_object->base_module); $meta_filter = "action_filter"; $action_processed = true; } if ($action_shell->action_type == "update_rel") { $rel_module = $workflow_object->get_rel_module($action_shell->rel_module); $temp_module = BeanFactory::getBean($rel_module); $meta_filter = "action_filter"; $action_processed = true; } if ($action_shell->action_type == "new") { $rel_module = $workflow_object->get_rel_module($action_shell->action_module); $temp_module = BeanFactory::getBean($rel_module); $meta_filter = "action_filter"; $action_processed = true; } if ($action_shell->action_type == "new_rel") { $rel_handler = $workflow_object->call_relationship_handler("base_module", true); $rel_handler->set_rel_vardef_fields($action_shell->rel_module, $action_shell->action_module); $rel_handler->build_info(true); $temp_module = $rel_handler->rel2_bean; $meta_filter = "action_filter"; $action_processed = true; } //BEGIN WFLOW PLUGINS if ($action_processed == false) { $opt['object'] = $this; $opt['workflow_object'] = $workflow_object; $opt['action_shell'] = $action_shell; $list_data_array = get_plugin("workflow", "action_createstep2", $opt); if (!empty($list_data_array['action_processed']) && $list_data_array['action_processed'] == true) { return $list_data_array['results']; } } //END WFLOW PLUGINS //Using VarDef Handler Object to obtain filtered array $temp_module->call_vardef_handler($meta_filter); $field_array = $temp_module->vardef_handler->get_vardef_array(); $field_count = 0; $result_array = array(); $actions = $action_shell->get_actions($action_shell->id); $action_fields = array(); foreach ($actions as $action) { if (!empty($action->field)) { //Check if the actions field is still valid (was not deleted or changed) if (empty($field_array[$action->field])) { //invalid field $result_array[] = array("ACTION_VALUE" => "", "ACTION_ACTION_ID" => "", "ACTION_SET_TYPE" => "", "ACTION_ADV_TYPE" => "", "START_DISPLAY" => "", "FIELD_NUM" => $field_count, "FIELD_VALUE" => $action->field, "FIELD_VALUE" => $action->field, "ACTION_DISPLAY_TEXT" => false, "ACTION_ADV_VALUE" => "", "ACTION_EXT1" => "", "ACTION_EXT2" => "", "ACTION_EXT3" => ""); if (!$get_all_fields) { ++$field_count; } continue; } $action_fields[$action->field] = $action->field; } } /* We should NOT be itterating over every field in the module per actionshell, * calling multiple queries per field just to throw out the results. * We should start with the list of actions and the fields they provide * if we are not attempting to add a new action. (when $get_all_fields is false) */ if (!$get_all_fields) { $field_array = $action_fields; } foreach ($field_array as $key => $value) { //check to see if this record exists already if (!empty($action_shell->id) && $action_shell->id != "") { $action_id = $action_shell->get_action_id($key); if ($action_id !== false) { $action_object = BeanFactory::getBean('WorkFlowActions', $action_id); $act_action_value = $action_object->value; $start_display = "none"; $act_id = $action_object->id; $act_set_type = $action_object->set_type; $act_adv_type = $action_object->adv_type; $start_display = ""; } else { $start_display = $this->target_bean->check_required_field("start_display", $temp_module, $key); $act_action_value = ""; $act_id = ""; $act_set_type = ""; $act_adv_type = ""; } } else { $action_id = false; $start_display = $this->target_bean->check_required_field("start_display", $temp_module, $key); $act_action_value = ""; $act_id = ""; $act_set_type = ""; $act_adv_type = ""; } if ($action_id !== false) { $act_adv_value = $action_object->value; $act_ext1 = $action_object->ext1; $act_ext2 = $action_object->ext2; $act_ext3 = $action_object->ext3; } else { $act_adv_value = ""; $act_ext1 = ""; $act_ext2 = ""; $act_ext3 = ""; } // get the label for the field $field = $temp_module->getFieldDefinition($value); $field_label = $value; if (is_array($field) && isset($field['vname'])) { // lets get the correct label $mod_strings = return_module_language($GLOBALS['current_language'], $temp_module->module_name); if (isset($mod_strings[$field['vname']])) { $field_label = str_replace(':', '', $mod_strings[$field['vname']]); } } $sub_array = array(); $sub_array["ACTION_VALUE"] = $act_action_value; $sub_array["ACTION_ACTION_ID"] = $act_id; $sub_array["ACTION_SET_TYPE"] = $act_set_type; $sub_array["ACTION_ADV_TYPE"] = $act_adv_type; $sub_array["START_DISPLAY"] = $start_display; $sub_array["FIELD_NUM"] = $field_count; $sub_array["FIELD_VALUE"] = $key; $sub_array["FIELD_NAME"] = $field_label; $sub_array["ACTION_DISPLAY_TEXT"] = get_display_text($temp_module, $key, $act_action_value, $act_adv_type, $act_ext1, array('for_action_display' => true)); $sub_array["ACTION_ADV_VALUE"] = $act_adv_value; $sub_array["ACTION_EXT1"] = $act_ext1; $sub_array["ACTION_EXT2"] = $act_ext2; $sub_array["ACTION_EXT3"] = $act_ext3; $result_array[] = $sub_array; ++$field_count; //end foreach } $combined_results = array(); $combined_results["RESULT_ARRAY"] = $result_array; $combined_results["TEMP_MODULE_DIR"] = $temp_module->module_dir; return $combined_results; }