/** * @see FWS_Module::init($doc) * * @param TDL_Document $doc */ public function init($doc) { parent::init($doc); $input = FWS_Props::get()->input(); $functions = FWS_Props::get()->functions(); $renderer = $doc->use_default_renderer(); $locale = FWS_Props::get()->locale(); $cfg = FWS_Props::get()->cfg(); $renderer->add_action(TDL_ACTION_EDIT_ENTRY, 'edit'); $renderer->add_action(TDL_ACTION_NEW_ENTRY, 'add'); $mode = $input->correct_var(TDL_URL_MODE, 'get', FWS_Input::STRING, array('add', 'edit'), 'add'); if ($mode == 'edit') { $id = $input->get_predef(TDL_URL_IDS, 'get'); $murl = TDL_URL::get_entry_url(); $murl->set(TDL_URL_ACTION, 'edit_entry'); $murl->set(TDL_URL_MODE, 'edit'); $murl->set(TDL_URL_IDS, $id); if (FWS_String::substr_count($id, ',') > 1) { $title = $locale->_('Edit entries'); } else { $title = $locale->_('Edit entry'); } } else { $murl = TDL_URL::get_mod_url(); $murl->set(TDL_URL_MODE, 'add'); $title = $locale->_('New entry'); } $renderer->set_has_access($mode == 'edit' || $cfg['project_id'] != 0); $renderer->add_breadcrumb($title, $murl->to_url()); }
/** * Returns all tokens from the given source * * @param string $source the source * @return array the tokens: <code>array(array(<token>,<string>,<line>), ...)</code> */ public static function get_tokens($source) { $line = 1; $res = array(); $tokens = token_get_all($source); foreach ($tokens as $token) { if (is_array($token)) { list($t, $str, ) = $token; } else { $t = $token; $str = $token; } $res[] = array($t, $str, $line); $lines = FWS_String::substr_count($str, "\n"); if ($lines >= 1) { $line += $lines; } } return $res; }